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