• Resolved sr3

    (@sr3)


    1) How can I add a logout link to a submenu? (e.g.: My Account -> Logout)

    2) I’m using buddypress and I already added “logout” to the submenu. But when I click on “logout” it redirects me to a page where I have to confirm that I really want to logout. Is there a way to avoid this and directly logout?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi sr3,
    I noticed that you marked this thread as resolved.
    Would you please share your solution with the community?
    Thanks ??

    Thread Starter sr3

    (@sr3)

    I couldn’t add it to the submenu, so I added it as the last item of my main-menu. But now it’s working.

    I added the following code at the end of the functions.php of my child-theme:

    add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);
    function add_login_logout_link($items, $args) {
    	ob_start();
    	wp_loginout('index.php');
    	$loginoutlink = ob_get_contents();
    	ob_end_clean();
    	$items .= '<li>'. $loginoutlink .'</li>';
    	return $items;
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add logout link to submenu’ is closed to new replies.