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.

Add GET query arguments to login redirect

Home Forums Community Forum Add GET query arguments to login redirect

This topic contains 5 replies, has 3 voices. Last updated by  Jason (Lead Developer) 4 years, 10 months ago.

Topic Author Topic
Posted: Sunday Feb 26th, 2012 at 8:07 pm #6481
Mark
Username: markeshark

I want to add query arguments to s2member’s login redirect URL like so: “welcome_page.php?foo=bar&boo=far” etc. via a plugin.

Without s2member I would simply put this in my plugin:

<?php 
add_filter( 'login_redirect', 'login_modify' );

function login_modify() {
	$location = "http://mysite.com/welcome";
	
	$location = add_query_args(array('foo'=>'bar'), $location );
	
	return $location;
}

?>

But I don’t want to interfere with s2member’s login redirect – how can I add these GET variables in a way compatible with s2?

Thanks!

Mark

  • This topic was modified 4 years, 10 months ago by  Mark.
  • This topic was modified 4 years, 10 months ago by  Mark.
  • This topic was modified 4 years, 10 months ago by  Mark.
  • This topic was modified 4 years, 10 months ago by  Mark.

List Of Topic Replies

Viewing 5 replies - 1 through 5 (of 5 total)
Author Replies
Author Replies
Posted: Monday Feb 27th, 2012 at 4:22 pm #6540

Hi Mark.

Well, you can try that if you want. s2Member’s Login Welcome Page setting will most likely be bypassed, but as long as you’re doing it on purpose and taking the user where you want and it’s not a mistake caused unknowingly by some other plugin, I think it’s fine.

Try it and see if it works fine for you. :)

Posted: Monday Feb 27th, 2012 at 4:26 pm #6542
Mark
Username: markeshark

I know that will work BUT my whole question is that I want it to work WITH s2member’s settings, not override them. Knowing S2’s good framework I’m sure there is an appropriate filter that will enable me to do this and that is what I was asking for.

  • This reply was modified 4 years, 10 months ago by  Mark.
Posted: Monday Feb 27th, 2012 at 4:34 pm #6546
Posted: Monday Feb 27th, 2012 at 5:04 pm #6568
Mark
Username: markeshark

I’ve looked through these already, the problem is the number of filters and I’m unfamiliar with the code. I’m pretty sure one of the programmers would be able to tell us within about 30 seconds which filter to use and/or if this is possible… can we get Jason to peek at this for a second?

Posted: Monday Feb 27th, 2012 at 10:55 pm #6633
Staff Member

Thanks for the heads up on this topic.
Please use this Hook: ws_plugin__s2member_during_login_redirect

Create this directory and file:
/wp-content/mu-plugins/s2-hacks.php
( these are MUST USE plugins, see: http://codex.wordpress.org/Must_Use_Plugins )

<?php
add_action("ws_plugin__s2member_during_login_redirect", "my_login_redirect");
function my_login_redirect($vars = array())
	{
		$location = get_page_link($GLOBALS&#91;"WS_PLUGIN__"&#93;&#91;"s2member"&#93;&#91;"o"&#93;&#91;"login_welcome_page"&#93;);
		$location = add_query_args(urlencode_deep(array("foo" => "bar")), $location);
		wp_redirect($location).exit();
	}
?>
Viewing 5 replies - 1 through 5 (of 5 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.