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:
http://. 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
http://yourfabulousmembershipsite.com/?custom_welcome_page=%%current_user_role%%
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]