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.

content only if redirected

Home Forums Community Forum content only if redirected

This topic contains 3 replies, has 2 voices. Last updated by  David Welch 4 years, 10 months ago.

Topic Author Topic
Posted: Friday Feb 17th, 2012 at 9:37 am #5486

I’m putting some [s2If] conditional output on my default Membership page. I want to display a message when the user is redirected to the Membership page, but not when the user comes there on purpose. What is the best way to accomplish this with s2member?

List Of Topic Replies

Viewing 3 replies - 1 through 3 (of 3 total)
Author Replies
Author Replies
Posted: Tuesday Feb 21st, 2012 at 2:43 pm #5894
David Welch
Username: dwbiz05

When someone is re-directed, there is a GET string in the url like this:

?_s2member_seeking[type]=page&_s2member_seeking[page]=55&_s2member_seeking[_uri]=L21lbWJlci1ob21l&_s2member_req[type]=level&_s2member_req[level]=0&_s2member_res[type]=sys&s2member_seeking=page-55&s2member_level_req=0

So, if you run a query on your page like:

if(isset($_GET['_s2member_seeking[type]'])){
//what you want to say in the ''.
echo '';
}

It should do what you want… I don’t know if this is an option with the s2member shortcodes, so if not, you can create your own shortcode in your theme’s functions.php file:

function redirected_user_message($atts, $content){	
	if(isset($_GET['_s2member_seeking[type]'])){
	return $content
	}
}

add_shortcode('redir-user-msg','redirected_user_message');

Then in your page or post just add this:

[redir-user-msg]
This is the message for redirected users.
[/redir-user-msg]

Again, s2member may have an option but I haven’t checked and don’t remember one off the top of my head.

Dave

Posted: Wednesday Feb 22nd, 2012 at 9:18 am #5940

With a few small modifications, that works a treat. Thanks!

function redirected_user_message($atts, $content){
	if(isset($_GET['_s2member_seeking']['type'])){ //regular array syntax
		return do_shortcode($content); //recursively manage any shortcodes in content
	}
}

add_shortcode('redir_user_msg','redirected_user_message');
Posted: Wednesday Feb 22nd, 2012 at 9:45 am #5945
David Welch
Username: dwbiz05

FYI, i’ve found that returning do_shortcode with the entire content doesn’t work all the time for me for some reason.. so double check that it works for any shortcode you are using.

Otherwise, you may have to use preg_replace with do_shortcode to make it work… at least I did.

Of course, I don’t always do things 100% right. lol!

Dave

Viewing 3 replies - 1 through 3 (of 3 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.