Customizing welcome page

Hi there,
I used the instruction from here http://www.peterrknight.com/2012/08/25/how-to-send-users-to-different-welcome-pages-based-on-user-level-in-s2member/ to customize for every level its Welcome page.
Everything was fine, but recently I had an emergency and after restored the plugins settings my customization didin’t work.
All levels redirects to home page or setting option Login Welcome Page, but I’d like to redirect to different welcome pages according to their levels.

Thanks

Did you place the PHP code from the article into a mu-plugin or did you put it somewhere else (such as your functions.php file)? If it was in a mu-plugin, check the Plugins page in your WordPress Dashboard to make sure the plugin is being loaded. If it was in functions.php or another file, it may have been lost when you restored your site. (At least, that’s what I think you said you did. :wink: )

Thanks for your reply!
This code is in functions.php.
The other functions from this file work and this one doesn’t work.
I don’t think this file is lost

I hadn’t looked closely at the code, but now that I have I see that you shouldn’t need that code at all. You can use a Special Redirection URL with the %%current_user_level%% replacement code to do the same thing. You may need to rename your welcome pages, though.

Try something like this in the Special Redirection URL box here WP Dashboard → s2Member →General Options → Login Welcome Page:

http://www.example.com/%%current_user_level%%-welcome-page

For more detailed instructions, see this s2Member KBA.

I need the next structure:
www.example.com/first-page for levels 1-3,
www.example.com/second-page for levels 4-6,
and else 2 similar groups

And I cannot rename Welcome Page

Here is my code

function your_member_site_vars( $vars ){

$vars[] = “custom_welcome_page”;
return $vars;
}
add_filter( ‘query_vars’, ‘your_member_site_vars’ );

function my_login_redirect() {
if ( get_query_var( ‘custom_welcome_page’ ) ) {
$role = get_query_var( ‘custom_welcome_page’ );
// double check if user has that role
if( current_user_can( $role ) ){
wp_redirect( my_member_welcome_pages( $role ) );
exit;
}
}
}
add_action( ‘template_redirect’, ‘my_login_redirect’ );
function my_member_welcome_pages( $role ){
$welcome_pages = array(
‘subscriber’ => ‘http://example.com/welcome-page/’,
‘s2member_level1’ => ‘http://example.com/first-page/’,
‘s2member_level2’ => ‘http://example.com/first-page/’,
‘s2member_level3’ => ‘http://example.com/first-page/’,
‘s2member_level4’ => ‘http://example.com/second-page/’,
‘s2member_level5’ => ‘http://example.com/second-page/’,
‘s2member_level6’ => ‘http://example.com/second-page/’,
‘s2member_level7’ => ‘http://example.com/third-page/’,
‘s2member_level8’ => ‘http://example.com/third-page/’,
‘s2member_level9’ => ‘http://example.com/thirdt-page/’,
‘s2member_level10’ => ‘http://example.com/fourth-page/’,
‘s2member_level11’ => ‘http://example.com/fourth-page/’,
‘s2member_level12’ => ‘http://example.com/fourth-page/’,
);

if( $welcome_pages[$role] ){
return $welcome_pages[$role];
} else {
return ‘http://example.com/welcome-page/’;
}
}

When does this function fire? What code triggers it?

The trigger is this hook ‘add_action( ‘template_redirect’, ‘my_login_redirect’ );’. It should replace welcome page

Do you have the Special Redirection URL set as described in your linked article?

http://yourfabulousmembershipsite.com/?custom_welcome_page=%%current_user_role%%

Thanks JediShark!
It was missing point.
Everything works fine.
I am very grateful to you.

Great! Always happy to help.