How To Send Users To Different Welcome Pages Based On User Level In S2Member

A very common requirement for membership sites is the ability to send a user that is logging in to a specific home page. With S2Member there are a couple of ways to accomplish this. I came across some solutions involving javascript, which I think is a bad idea for a number of reasons. I’ll share one method here that is relies on some server side magic instead. To implement this you’ll need to write a little bit of code and insert it in your plugin file, your theme’s functions.php or your s2hacks.php file.

The first clue to redirecting users after logging is the UI S2Member provides under ‘General Options’. There is a section called ‘Login Welcome Page’, which is what we’re after. Here S2Member gives you the option to select an existing page from a dropdown. We don’t want that option because it will be the generic welcome page for all user levels/roles. To send users to different pages based on their membership level, we can make use of the field below the drop down.

 Or, you may configure a Special Redirection URL, if you prefer. You’ll need to type in the full URL, starting with: 


A few Replacement Codes are also supported here.

It’s basically a text field that let’s you specify a url. The cool thing is that we can utilize dynamic variables in the url with replacement codes. The solution I’m using here involves using the %%current_user_role%% replacement code as a GET parameter in the url. What you get is a url that looks like

The words custom_welcome_page can be replaced with a wording of your choosing (make it unique though) and the %%current_user_role%% will be dynamically replaced with the membership level of the user that is signing in.

For the next step, we are going to write the code that tells WordPress to interpret those parameters.

[php]function your_member_site_vars( $vars ){

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

And now WordPress will interpret the parameter we’re using, we have to tell what to do when it is used next.


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 ) );

add_action( ‘template_redirect’, ‘my_login_redirect’ );


What the above code does is listen to the parameter custom_welcome_page in the url, if it  is found then it will try to redirect the user. To determine the page, we write another function that takes the membership level of the user and returns the appropriate url.

[php]function my_member_welcome_pages( $role ){

// Set the welcome pages in the following array

$welcome_pages = array(
‘subscriber’ => ‘’,
‘s2member_level1’ => ‘’,
‘s2member_level2’ => ‘’

if( $welcome_pages[$role] ){
return $welcome_pages[$role];
} else {
return ‘’;

These functions are the basic functionality needed to create your own custom welcome page redirects for your members.

Would you like to have a plugin with a simple user interface that does this for you? Drop me a line.



  1. Daniela says:

    I’m sorry but I don’t write very well in English.
    I do not understand how to run these commands with the free level (level0).
    Can you explain?

    thank you

    • Peter Knight says:

      Hi Daniela,

      How far did you get with the example in the post? I’ve added a free level0 example in the code which should work the same as the other levels.

      • Daniela says:


        Thank you for the quick response.

        I had already tried the same command, but after putting livel0’s username and password to access the page “Membership Options Page.”

        I don’t now where am I wrong.

        Thank you

  2. marty says:

    I would like to work with you to get this functionality operational,

    I am uncertain where to place the different php code segments above in my site.

    there are 3 separate [php] to [/php] elements, do they all go into the functions.php in that order at the end or is placement within the functions.php specific?

  3. Kyle S says:


    Im trying to use your code, it appears most of my functions are correcct. However when i log in under certain user level, i get the address \”\” and sends me to the home page. it appears the redirect portion isnt actually redirecting.

    ‘subscriber’ => \’\’,
    ‘s2member_level1’ => \’\’,
    ‘s2member_level2’ => \’\’

Leave a Reply

Your email address will not be published.