How can I edit the membership login area tabs?

Discussion in 'aMember Pro v.4' started by mporter9, Jan 13, 2013.

  1. mporter9

    mporter9 Member

    Joined:
    Aug 25, 2012
    Messages:
    83
    Hi,

    Right now when one of my members logs in they can see the follow tabs in their membership area:

    Main Page, Add/Renew Subscription, Payments History, Edit Profile, Affiliate Info, and Helpdesk.

    How can I edit these? I just want it to have tabs for Main Page, Edit Profile, and Helpdesk.

    Thanks for the help.
  2. thehpmc

    thehpmc aMember Pro Customer

    Joined:
    Aug 24, 2006
    Messages:
    901
  3. sarah_rendle

    sarah_rendle aMember Pro Customer

    Joined:
    Apr 3, 2014
    Messages:
    69
    I too am interested in this but can't see where the site.php file is placed can anyone help?

    I found the file site-dist.php and renamed this as instructed to site.php. I then uploaded the code as per the information above only to get an error message.
  4. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,689
    I believe you incorrectly copy code to site.php file. Could you please attache content of your file.
  5. sarah_rendle

    sarah_rendle aMember Pro Customer

    Joined:
    Apr 3, 2014
    Messages:
    69
    <?php
    Am_Di::getInstance()->hook->add('userMenu', 'siteUserMenu');
    function siteUserMenu(Am_Event $event)
    {
    // $user = $event->getUser(); // if required
    $menu = $event->getMenu();

    // Add a single tab
    $menu->addPage(array(
    'id' => 'mypage',
    'label' => ___('Do The Thing'),
    'uri' => '/the.thing',
    'order' => 2,
    ));

    // Add a tab with subitems
    $menu->addPage(
    array(
    'id' => 'with-subitem',
    'label' => 'With Subitems',
    'uri' => '#',
    'pages' => array(
    array(
    'id' => 'subitem1',
    'label' => 'Subitem 1',
    'uri' => '/subitem-2'
    ),
    array(
    'id' => 'subitem2',
    'label' => 'Subitem 2',
    'uri' => '/subitem-2'
    )
    )
    )
    );

    // Remove a tab
    $page = $menu->findOneBy('id', 'add-renew');
    $menu->removePage($page);

    // Add sub item to exiting tab
    $page = $menu->findOneBy('id', 'aff'); // get affiliate page
    $page->addPage(array(
    'id' => 'my-subitem',
    'label' => ___('Subitem'),
    'uri' => '/sub.item',
    'target' => '_blank', // you can set target attribute if necessary
    'order' => 10,
    ));

    //Add a tab based on user access, if user has active subscription to product with # 1
    /* @var $user User */
    $user = $event->getUser();
    if (in_array(1, $user->getActiveProductIds())) {
    $menu->addPage(array(
    'id' => 'mypage',
    'label' => ___('Do The Thing'),
    'uri' => '/the.thing',
    'order' => 2,
    ));
    }
    }
  6. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,689
    Is it all that you have in site.php file? What is error you got?
  7. sarah_rendle

    sarah_rendle aMember Pro Customer

    Joined:
    Apr 3, 2014
    Messages:
    69
    it was yes. the error was:

    Fatal error: Call to a member function addPage() on a non-object in /home/pdhub/public_html/coaching4everyone/amember/application/configs/site.php on line 43
  8. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,689
    Please use this code instead
    Code:
    <?php
     
    Am_Di::getInstance()->hook->add('userMenu', 'siteUserMenu');
     
    function siteUserMenu(Am_Event $event)
    {
    // $user = $event->getUser(); // if required
        $menu = $event->getMenu();
     
    // Add a single tab
        $menu->addPage(array(
            'id' => 'mypage',
            'label' => ___('Do The Thing'),
            'uri' => '/the.thing',
            'order' => 2,
        ));
     
    // Add a tab with subitems
        $menu->addPage(
            array(
                'id' => 'with-subitem',
                'label' => 'With Subitems',
                'uri' => '#',
                'pages' => array(
                    array(
                        'id' => 'subitem1',
                        'label' => 'Subitem 1',
                        'uri' => '/subitem-2'
                    ),
                    array(
                        'id' => 'subitem2',
                        'label' => 'Subitem 2',
                        'uri' => '/subitem-2'
                    )
                )
            )
        );
     
    // Remove a tab
        $page = $menu->findOneBy('id', 'add-renew');
        $menu->removePage($page);
     
     
    //Add a tab based on user access, if user has active subscription to product with # 1
        /* @var $user User */
        $user = $event->getUser();
        if (in_array(1, $user->getActiveProductIds())) {
            $menu->addPage(array(
                'id' => 'mypage',
                'label' => ___('Do The Thing'),
                'uri' => '/the.thing',
                'order' => 2,
            ));
        }
    }
  9. sarah_rendle

    sarah_rendle aMember Pro Customer

    Joined:
    Apr 3, 2014
    Messages:
    69
    Hi caesar - this works brilliant. Thanks
  10. sarah_rendle

    sarah_rendle aMember Pro Customer

    Joined:
    Apr 3, 2014
    Messages:
    69
    I do want to remove the payment history tab and found this code. which works. but combining your code and this together I get an error can you please explain using your code what I need to do to remove the payment history tab please.

    sarah x


    <?php
    Am_Di::getInstance()->hook->add(Am_Event::GET_MEMBER_LINKS, 'getLinks');
    function getLinks(Am_Event $event){
    $event->addReturn('e-Coaching Area', 'http://coaching4everyone.pd-hub.com');
    }
    if (!defined('INCLUDED_AMEMBER_CONFIG'))
    die("Direct access to this location is not allowed");

    /*
    * aMember Pro site customization file
    *
    * Rename this file to site.php and put your site customizations,
    * such as fields additions, custom hooks and so on to this file
    * This file will not be overwritten during upgrade
    *
    */


    Am_Di::getInstance()->hook->add('userMenu', 'siteUserMenu');
    function siteUserMenu(Am_Event $event)
    {
    // $user = $event->getUser(); // if required
    $menu = $event->getMenu();

    // remove a page
    $page = $menu->findOneBy('id', 'add-renew');
    $menu->removePage($page);

    // remove a page
    $page = $menu->findOneBy('id', 'payment-history');
    $menu->removePage($page);
    }
  11. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,689
    As I can see your code is correct. What do you want to achieve?
  12. sarah_rendle

    sarah_rendle aMember Pro Customer

    Joined:
    Apr 3, 2014
    Messages:
    69
    Both codes work individually. But I would like to use your code but remove the payment history tab.

    Sarah
  13. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,689
    Yes, I got it. I mean what exactly you want to implement with code from example. Example code has many example I do not think you actually need all of them. But if you want to incorporate all code it will be
    Code:
    <?php
     
    if (!defined('INCLUDED_AMEMBER_CONFIG'))
        die("Direct access to this location is not allowed");
     
    /*
    * aMember Pro site customization file
    *
    * Rename this file to site.php and put your site customizations,
    * such as fields additions, custom hooks and so on to this file
    * This file will not be overwritten during upgrade
    *
    */
     
     
    Am_Di::getInstance()->hook->add(Am_Event::GET_MEMBER_LINKS, 'getLinks');
     
    function getLinks(Am_Event $event)
    {
        $event->addReturn('e-Coaching Area', 'http://coaching4everyone.pd-hub.com');
    }
     
    Am_Di::getInstance()->hook->add('userMenu', 'siteUserMenu');
     
    function siteUserMenu(Am_Event $event)
    {
    // $user = $event->getUser(); // if required
        $menu = $event->getMenu();
     
    // remove a page
        $page = $menu->findOneBy('id', 'add-renew');
        $menu->removePage($page);
     
    // remove a page
        $page = $menu->findOneBy('id', 'payment-history');
        $menu->removePage($page);
    // Add a single tab
        $menu->addPage(array(
            'id' => 'mypage',
            'label' => ___('Do The Thing'),
            'uri' => '/the.thing',
            'order' => 2,
        ));
     
    // Add a tab with subitems
        $menu->addPage(
            array(
                'id' => 'with-subitem',
                'label' => 'With Subitems',
                'uri' => '#',
                'pages' => array(
                    array(
                        'id' => 'subitem1',
                        'label' => 'Subitem 1',
                        'uri' => '/subitem-2'
                    ),
                    array(
                        'id' => 'subitem2',
                        'label' => 'Subitem 2',
                        'uri' => '/subitem-2'
                    )
                )
            )
        );
     
     
    //Add a tab based on user access, if user has active subscription to product with # 1
        /* @var $user User */
        $user = $event->getUser();
        if (in_array(1, $user->getActiveProductIds())) {
            $menu->addPage(array(
                'id' => 'mypage',
                'label' => ___('Do The Thing'),
                'uri' => '/the.thing',
                'order' => 2,
            ));
        }
    }
     
    
  14. paeon

    paeon New Member

    Joined:
    Apr 27, 2009
    Messages:
    1
    Using code like the above, how do we make the selected tab stay highlighted when selected, like the default tabs?
    Do we need another option 'activeClass' => 'active' or similar?

    any help greatly appreciated
  15. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,689
    You need to detect somehow that your page is active now and then use this code to set it active
    Code:
    $menu->findOneBy('id', 'mypage')->setActive(true);

Share This Page