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.

How to redirect a user to register

Home Forums Community Forum How to redirect a user to register

This topic contains 7 replies, has 3 voices. Last updated by  adam chen 4 years, 10 months ago.

Topic Author Topic
Posted: Friday Feb 10th, 2012 at 5:11 pm #4780
adam chen
Username: adam1987

Hi, everyone:

I konw the section “Membership Option Page” suppose to be redirected once unregistered user access premium content, but I just want to redirect whoever that is to register page. How can I do that, since register page is NOT really a page but a html code……

Thank You

List Of Topic Replies

Viewing 7 replies - 1 through 7 (of 7 total)
Author Replies
Author Replies
Posted: Saturday Feb 11th, 2012 at 6:16 am #4808
Bendix
Username: benchefe

You want your (registered) users to be redirected to your register page ?
I don’t understand what for, but ok :)

If you want to use different levels or custom capabilities you can use the shortcodes as mentioned in s2member – API scripting – simple/shortcode conditions.
So you can easily use the shortcodes for displaying different content on a page for different levels or custom capabilities (maybe a link to your registration page).

greetings

Posted: Saturday Feb 11th, 2012 at 3:30 pm #4828
David Welch
Username: dwbiz05

I think what adam is saying is that he wants Unregistered people to be redirected to the registration page instead of a wordpress “page” like the ones listed in the dropdown on the s2member options.

My suggestion would be to add a function that hooks into s2member to disrupt the normal redirection process. I did a little testing and this seemed to work for me:

1. Create a new file (if you don’t have one) in wp-content/mu-plugins/ called s2-hacks.php. You may also need to create the mu-plugins directory.

2. add this to that new s2-hacks.php file:

function dw_custom_redirect($vars = array()){

	//This redirects to the registration url (assuming it's a standard install)
	wp_redirect(site_url('/wp-login.php?action=register'));
	exit();
	
}

//This adds to the hook when the system calls for the "membership-options" page.
add_action("ws_plugin__s2member_before_wp_redirect_w_mop_vars","dw_custom_redirect");

3. Save the file and test it out.

Non-logged in users should be re-directed to the registration page now.

Again, I have not done extensive testing but it seems to work for me.

Hope that helps,
Dave

Posted: Monday Feb 13th, 2012 at 11:47 am #4935
adam chen
Username: adam1987

Hi David:

I tried, but seem its not really work.

I did exactly the steps, but seem its not only not working, but also the original php code simply appear on the top of the page.

Is there something wrong or should I do some extra steps to apply the s2-hacks.php?

Posted: Monday Feb 13th, 2012 at 8:23 pm #4968
David Welch
Username: dwbiz05

You need to wrap it in the following php tags.

<?php
//the code I gave you here
?>

Dave

  • This reply was modified 4 years, 10 months ago by  David Welch.
Posted: Monday Feb 13th, 2012 at 8:36 pm #4972
adam chen
Username: adam1987

oh~ thanks, let me see if it wokrs good, will reply you tomorrow, thanks for your kind help :)

Posted: Tuesday Feb 14th, 2012 at 9:57 am #5029
adam chen
Username: adam1987

Problem……….now

  • This reply was modified 4 years, 10 months ago by  adam chen.
Posted: Wednesday Feb 15th, 2012 at 10:54 am #5225
adam chen
Username: adam1987

Hi, David ( and whoever may care):

I think there is another issue:
When I actually get in the login Welcome page directly, it will not redirect me to the register page if I am not a registered user.
Also when I registered as a new user, after login, it also redirect me to the register screen….thats not right….
I wonder how could I fix that with that brilliant hook David wrote?

Anyone?

Thanks ahead!

  • This reply was modified 4 years, 10 months ago by  adam chen.
Viewing 7 replies - 1 through 7 (of 7 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

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.