latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

About: Andy Ogden

Sorry, I've not written a description yet. I'll get to it soon!


My Favorite Topics

Viewing 2 topics - 1 through 2 (of 2 total)
Topic Count Last Reply
%%current_user_login%% Menu Button

By:  Alex Robertson in: Community Forum

voices: 2
replies: 3

4 years, 6 months ago  Andy Ogden

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

Topics I'm Subscribed To

Viewing 2 topics - 1 through 2 (of 2 total)
Topic Count Last Reply
%%current_user_login%% Menu Button

By:  Alex Robertson in: Community Forum

voices: 2
replies: 3

4 years, 6 months ago  Andy Ogden

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

Topics I've Started

Viewing topic 1 (of 1 total)
Topic Count Last Reply
Viewing topic 1 (of 1 total)

My Latest Replies (From Various Topics)

Viewing 2 replies - 1 through 2 (of 2 total)
Author Replies
Author Replies
Posted: Thursday Jun 21st, 2012 at 10:07 am #17128

Unfortunately I didn’t get a response to this with a quick fix, but I wanted to help out anyone with a similar query by posting the answer I came up with.

It’s not difficult, it’s just a little outside my comfort zone and I must’ve got the syntax wrong first time, as I swear I tried this once already.

add_filter( 'wp_nav_menu_items', 'add_member_link', 10, 2 );

function add_member_link( $items, $args ) {

    if (is_user_logged_in() && $args->theme_location == 'members') {
        $items .= '<li class="menu-item menu-item-type-post_type menu-item-object-page"><a href="http://www.andyogden.co.uk/members/'.S2MEMBER_CURRENT_USER_LOGIN.'">Member Area</a></li>';
    }
    return $items;

Hope someone finds this useful, especially beginners like me!

Posted: Thursday Jun 21st, 2012 at 10:04 am #17127

I’ve been trying to find out how to do the same thing and just managed to get it working, so hopefully you’ll find my solution helpful. You seem to have gone down the redirect route, but since your original request was for a menu button I’m hoping you’re still interested.

I’ve created a members only version of the menu and then used a function to add an additional button which includes the a page I’ve created that matches their custom capability.

Dependant Setup: –

  • Each user account has a custom capability defined that matches their username exactly.
  • Create a page with the same name, or at least the same slug as the custom capability. This page will act as the users personal homepage

Optional Setup: –

To add an extra menu in WordPress you can use the following article – http://codex.wordpress.org/Function_Reference/register_nav_menus
But essentially something like this, which should be found in functions.php

register_nav_menus( array(
	'public_menu' => 'Public Menu',
	'member_only' => 'Members Only Menu'
) );

This is accompanied by a change in header.php to decides which version of the menu a user gets to see depending on whether they’re logged in or not

if ( is_user_logged_in() ) {
	wp_nav_menu( $member_args );
	} else {
	wp_nav_menu( $visitor_args );
}

What I did here is to leave a ‘Member Area’ item on the public menu which pointed to wp-admin so that the user can log in. The members only version of the menu doesn’t have this option and my solutions continues…

In functions.php add a new function

// Changes to insert a member area only link to direct users to their personal home page
add_filter( 'wp_nav_menu_items', 'add_member_link', 10, 2 );

function add_member_link( $items, $args ) {

    if (is_user_logged_in() && $args->theme_location == 'members') {
        $items .= '<li class="menu-item menu-item-type-post_type menu-item-object-page"><a href="http://www.andyogden.co.uk/members/'.S2MEMBER_CURRENT_USER_LOGIN.'">Member Area</a></li>';
    }
    return $items;
}
// End of change by AO
Viewing 2 replies - 1 through 2 (of 2 total)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.