Version 4 Remove Tabs

Discussion in 'Templates customization' started by kenmomentum, Nov 19, 2013.

  1. kenmomentum

    kenmomentum New Member

    Joined:
    Apr 1, 2011
    Messages:
    26
    Hello Great Support

    1. I had to finally upgrade to version 4 due WHM needs to upgrade MySQL and version 3 does not handle the upgrade.

    2. I was afraid that the mods on version 4 are going to take me a while to grasp

    3 I went to the following link:
    http://www.amember.com/docs/How_to_customize_user_tabs_in_member's_area

    I did create the site.php file

    I added the following to the site.php file
    // Remove a tab
    $page = $menu->findOneBy('id', 'add-renew');
    $menu->removePage($page);

    I want to remove the "Add/Renew Subscription" button

    When added to the site.php I get the following error on the page.Fatal error: Call to a member function findOneBy() on a non-object in
    /home/mywebsite/public_html/myfolder/amembernew/application/
    configs/site.php
    on line 17

    In the site.php file I have the following
    <?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
    *
    */


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

    I am sure I missed something?

    Can you help?
  2. kenmomentum

    kenmomentum New Member

    Joined:
    Apr 1, 2011
    Messages:
    26
    Hello Again

    I kept on searching and found the answer.

    making modifications on this is not as easy as 3.x

    I did the the following and the buttons are gone
    <?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('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);
    }

    Am_Di::getInstance()->blocks->add(new Am_Block('member/main/left', 'My Block Title', 'my-block-id', null, 'renderMyBlock'));

    function renderMyBlock() {
    $html = <<<CUT
    <p>You can put some html code here</p>
    CUT;
    return $html;
    }

    //remove block with id member-main-unsubscribe
    Am_Di::getInstance()->blocks->remove('member-main-active-subscriptions');
    sarah_rendle likes this.
  3. pkrpkram

    pkrpkram New Member

    Joined:
    Apr 26, 2011
    Messages:
    7
    Thanks for publishing this - couldn't get the first setup to work either.
    It looks like the missing piece was
    $menu = $event->getMenu();
    It works for me now without the rendering part added.
  4. arthy

    arthy aMember Pro Customer

    Joined:
    Aug 22, 2006
    Messages:
    87
    just wanted to let others know
    remove tab code from the following page dont work:
    http://www.amember.com/docs/How_to_customize_user_tabs_in_member's_area

    u need to use:

    Am_Di::getInstance()->hook->add(Am_Event::USER_MENU, function (Am_Event $event) {
    $user = $event->getUser();
    $menu = $event->getMenu();

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


    atleast for me the above code worked only.
  5. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    @arthy you are right. Code on these page had typo (missed semicolon). I fixed it now.
  6. arthy

    arthy aMember Pro Customer

    Joined:
    Aug 22, 2006
    Messages:
    87
    Thanks, could you tell me how to remove a subitem within a tab ? this information is not present on that page, and i have spend some time trying to fix it myself, but was unable to.

    would be great if you could add that code to the wiki list so others can benefit too.
  7. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295

Share This Page