New Landing How can we help? Atelier User menu items

Viewing 2 posts - 1 through 2 (of 2 total)
  • Posted in: Atelier
  • #228445
    NMillard
    Member
    Post count: 115

    Hi!

    I’ve installed BBPress and now want to create links to the user area as well as a logout link.

    But I am having a few probs… I don’t know how to create these links in the main menu.

    It’s no problem to create a widget with the links but I also want them in the main menu… I’ve attached two imgs that might help explain what I mean.

    Do you have any suggestions on how to make this work?

    Attachments:
    You must be logged in to view attached files.
    #228520
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Please paste this code at functions.php of child theme.

    add_filter( 'wp_nav_menu_items', 'sf_loginout_menu_link', 10, 2 );
    
    function sf_loginout_menu_link( $items, $args ) {
       if ($args->theme_location == 'main') {
          if (is_user_logged_in()) {
             $items .= '<li class="sf_logout"><a href="'. wp_logout_url() .'">Log Out</a></li>';
          } else {
             $items .= '<li class="sf_login"><a href="'. wp_login_url(get_permalink()) .'">Log In</a></li>';
          }
       }
       return $items;
    }
    

    Thanks
    Mohammad

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register