Move Login link to main navigation

Discussion in 'aMember Pro v.4' started by rendersnag, Dec 1, 2011.

  1. rendersnag

    rendersnag Member

    Joined:
    Jan 28, 2011
    Messages:
    35
    hello...

    i have set up a child theme and am also using the wordpress plugin to pull in the header/footer.
    i would like to move the login/logout link into the main navigation. how would i go about doing that using a child theme?

    any info would be greatly appreciated!
  2. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    Think this will depend on the theme- if it can handle adding widgets to the navigation. Or it might require custom coding or editing to the theme.

    David
  3. gswaim

    gswaim CGI-Central Partner

    Joined:
    Jul 2, 2003
    Messages:
    641
    Assuming your main navigation is built using the WordPress custom menu utility you can easily add a menu item that points to "http://yoursite.com/amember/login" This page also provides a link to the signup pages.

    The problem it is a little tricky to have the menu choice switch to "Log Off"" after the user has logged in. You also need to provide the user a way to get to "http://yoursite.com/amember/member" so they can edit their profile and purchase additional products.

    So, a better solution is to set up a placeholder in the main menu and call it something like "My Account". You create a place holder in custom menus by creating a custom link with the pound sign "#" in the link box. The add all the other links as sub menus so they will fly out as you hover over "My Menu".

    Use a menu structure that looks something like this:

    My Account <- In the main menu bar - Points to "#"
    Login <- Points to "http://yoursite.com/login"​
    Signup <- Points to "http://yoursite.com/members"​
    Edit Profile <- Points to "http://yoursite.com/amember/profile"​

    Example:

    amember_in_menu.png
  4. rendersnag

    rendersnag Member

    Joined:
    Jan 28, 2011
    Messages:
    35
    Hello gswaim!

    Wow..thanks for that bit of info! I didn't even think to put the login/logout button in the Wordpress nav. May consider it.

    The navigation i was talking about is the one that displays when you are logged into amember. It consists of 'main menu', 'add/renew subscription', ect...
    What i'd like to do is add the logout link to that nav as well as a couple more links.
    Could i just find the file that has those links in them, copy the file to my theme folder and edit it from there?
    As of right now, not sure what file that is, but i'll continue to poke around.

    Again, thanks, and i guess i should have been more clear in the beginning.
  5. gswaim

    gswaim CGI-Central Partner

    Joined:
    Jul 2, 2003
    Messages:
    641
    OK.... Now I am going to assume you are talking about the aMember Widget. And if you are not, that would be the best way to handle this.

    The aMember Widget provides a way to login for guests (also provides a link to registration). After logging in it then provides a log out link. You can add more links in the widget configuration which is covered on this page in the Version 4 Wiki.

    If you want to add some custom links you will need to modify the WordPress plugin files.
  6. rendersnag

    rendersnag Member

    Joined:
    Jan 28, 2011
    Messages:
    35
    Hi Grant,

    Nope..not the aMember widget either ; )

    It's the menu in the members area.
    In the _menu.phtml file, i see this code:

    PHP:
    $m = new Am_View_Helper_Menu();
    $m->setView($this);

    echo 
    $m->renderMenu($this->di->navigationUser,
        array(
            
    'ulClass' => '',
            
    'activeClass' => 'active',
            
    'normalClass' => 'normal',
            
    'disabledClass' => 'disabled',
            
    'maxDepth' => 1,
        )
    );
    Where does this menu get built and how can I add menu items to it?
    Again...any help is greatly appreciated!
  7. adimac

    adimac New Member

    Joined:
    Nov 19, 2008
    Messages:
    4
    Hi rendersnag
    Did you get an answer for your question.
    I also want to modify these links but within the amember, I am not using wordpress.
    For my design I need to remove Add/Renew Subscription which is displayed on top after the member is signed in. This is not needed for my project and only will cause confusion.

    Please let me know if you have manage to edit your _menu.phtml file

    Many thanks
  8. boernerrha

    boernerrha aMember Pro Customer

    Joined:
    Nov 16, 2011
    Messages:
    28
    I also need to know how to add buttons to the amember menu bar to integrate it with my website. I want to relabel the Main Page button to Member Benefits and also install a Home and Forum button.
  9. boernerrha

    boernerrha aMember Pro Customer

    Joined:
    Nov 16, 2011
    Messages:
    28
    I think I found it but it's going to require a hack.

    Menu items are added via an array in Library/Am/Navigation/User.php. Each menu item also needs a controller class instance that is defined in a separate file in the Application/Default/Controllers folder so we'll probably have to create a surrogate class for each tab.

    If anybody tries this before I do please let me know what you learn.
  10. boernerrha

    boernerrha aMember Pro Customer

    Joined:
    Nov 16, 2011
    Messages:
    28
    Here is how to add a custom button to the amember menu that sends your user to a page of your choice. THIS IS A HACK, use at your own risk and be prepared to replace the files whenever aMember is updated. Also, read the security note at the end of the post.

    For this example we will add a 'Home' button at the beginning of the menu.

    In library/am/navigation/user.php find function addDefaultPages().

    For each new button add an array element like this:

    $this->addPage(array(
    'id' => 'home',
    'controller' => 'home',
    'action' => 'index',
    'label' => ___('Home'),
    'order' => 0
    ));

    'id' should be the same as 'controller'.

    'controller' must be unique and will be used as the prefix for a matching controller filename.

    'action' will be the function call that runs when the controller class instantiates. If you omit the action value pair then the button will be highlighted as being active and, of course, will do nothing.

    'label' will be the button label. Add an array element to match 'label' in application/default/language/user/default.php and any of the translation files you need:

    'Home' => 'Home',

    'order' determines the sequence of the button in the menu, left to right. Change the order values in the other button declarations so that each one is different.

    Create a new class declaration file in the application/default/controllers folder. Name the file such that the file begins with the value of 'controller' but with the initial character in upper case. The prefix must be appended to 'Controller'. The file extension must be '.php':

    HomeController.php

    The new controller file must contain the following specific subclass declaration containing at least one function and that function must be named with a prefix that matches the value of 'action' in the button array appended to the word 'Action'. To have the button send your user to a new page include a php redirect (header) command in that function:

    [begin code]

    <?php

    class HomeController extends Am_Controller
    {
    function indexAction()​
    {​


    }​

    }

    [end code]

    Note that there is no terminal '?>' tag in the controller file.

    The redirect url should probably be a location outside your amember folder so that you don't risk breaking the security of aMember.

Share This Page