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.

conditional redirect

Home Forums Community Forum conditional redirect

This topic contains 11 replies, has 4 voices. Last updated by  Eduan 4 years, 1 month ago.

Topic Author Topic
Posted: Monday Nov 19th, 2012 at 6:29 pm #32022
Leo Woer
Username: lewo

List Of Topic Replies

Viewing 11 replies - 1 through 11 (of 11 total)
Author Replies
Author Replies
Posted: Monday Nov 19th, 2012 at 6:37 pm #32023
Leo Woer
Username: lewo

oops ! I can see my script gets corrupted – I try again without the php

if(S2MEMBER_CURRENT_USER_LOGIN_COUNTER<1){?>
1st time welcome
} else if(S2MEMBER_CURRENT_USER_LOGIN_COUNTER>=1){
$welcome_page = “http://s2test.mindfolding.com/&#8221;;
}
?>
script type=”text/javascript”>

window location = ” echo $welcome_page; “;
//–>”

Posted: Tuesday Nov 20th, 2012 at 2:11 am #32056

It looks like your code didn’t come out right in your posts. You need to put the code inside HTML [hilite mono]<[/hilite][hilite mono]code>[/hilite] tags. Please post it again so I see what you are actually using.

s2Member Pro has a redirection based on logins which you can use to show that special page on first login: [hilite path]Dashboard -› s2Member® -› General Options -› One-Time Offers (Upon Login)[/hilite]

Posted: Tuesday Nov 20th, 2012 at 3:01 am #32059
Leo Woer
Username: lewo
<?php if(S2MEMBER_CURRENT_USER_LOGIN_COUNTER<1){?>

1st time welcome

<?php } else if(S2MEMBER_CURRENT_USER_LOGIN_COUNTER>=1){

$welcome_page = "http://s2test.mindfolding.com/";

}

?>

script type=”text/javascript”>
<!--
window location = "<?php echo $welcome_page; ?>";

//–>
</script>
Posted: Tuesday Nov 20th, 2012 at 9:34 am #32093
Eduan
Username: Eduan
Moderator

Hello Leo,

I believe that should work correctly like you want it, don’t know if it’ll have problems because it’s inside the JavaScript, but I don’t think it should. :)

Might I suggest you use the following logic however:

<?php if(S2MEMBER_CURRENT_USER_LOGIN_COUNTER < 1) {?>

	1st time welcome
<?php } elseif(S2MEMBER_CURRENT_USER_LOGIN_COUNTER >= 1) {

	$welcome_page = "http://s2test.mindfolding.com/"; ?>

	<script type="text/javascript">
		<!--
		window.location = "<?php echo $welcome_page; ?>"
		-->
	</script>
<?php } ?>

This would make sure that the structure and logic are correct, and it’s also more readable if somebody else comes along. :)

Hope this helps. ;)

  • This reply was modified 4 years, 1 month ago by  Eduan.
  • This reply was modified 4 years, 1 month ago by  Eduan. Reason: Fixed code
Posted: Tuesday Nov 20th, 2012 at 11:20 am #32107
Leo Woer
Username: lewo

Thank you sir,

have just tried it, where I replaced the

1st time welcome

with the content of the page – and I got the following error

Welcome

Parse error: syntax error, unexpected T_VARIABLE in /home/lewo/public_html/s2test/wp-content/plugins/exec-php/includes/runtime.php(42) : eval()’d code on line 32

I guess it is something with a parenthesis – what is wrong ?

Posted: Tuesday Nov 20th, 2012 at 4:59 pm #32152
Raam Dev
Username: Raam
Staff Member

Eduan’s code was missing a ? in one of the tags.

Please try this fixed code:

<?php if(S2MEMBER_CURRENT_USER_LOGIN_COUNTER < 1) {?>

	1st time welcome
<?php } elseif(S2MEMBER_CURRENT_USER_LOGIN_COUNTER >= 1) {

	$welcome_page = "http://s2test.mindfolding.com/"; ?>

	<script type="text/javascript">
		<!--
		window.location = "<?php echo $welcome_page; ?>"
		-->
	</script>
<?php } ?>
Posted: Wednesday Nov 21st, 2012 at 5:42 pm #32281
Leo Woer
Username: lewo

Tried it – exactly the same error as before

parse error: syntax error, unexpected T_VARIABLE in /home/lewo/public_html/s2test/wp-content/plugins/exec-php/includes/runtime.php(42) : eval()’d code on line 35

rgds
Leo

Posted: Wednesday Nov 21st, 2012 at 5:59 pm #32282
Leo Woer
Username: lewo

the funny thing is that this gives no error :

<?php if(S2MEMBER_CURRENT_USER_LOGIN_COUNTER >= 1) {
	$welcome_page = "http://s2test.mindfolding.com/"; ?>
	<script type="text/javascript">
		<!--
		window.location = "<?php echo $welcome_page; ?>"
		-->
	</script>
<?php } ?>
1st time welcome

However it also not work as it sends a user with no login counter to the same page, so no users go to 1st time welcome.

Posted: Wednesday Nov 21st, 2012 at 6:08 pm #32284
Eduan
Username: Eduan
Moderator

Well, in order for non-users to see another content, you would simply do the following:

<?php if (S2MEMBER_CURRENT_USER_IS_LOGGED_IN) {
	# Content for logged in users goes here.
	if (S2MEMBER_CURRENT_USER_LOGIN_COUNTER < 1) { ?>

		1st time welcome.
	<?php } elseif (S2MEMBER_CURRENT_USER_LOGIN_COUNTER >= 1) {

		$welcome_page = "http://s2test.mindfolding.com/"; ?>
	
		<script type="text/javascript">
			<!--
			window.location = "<?php echo $welcome_page; ?>"
			-->
		</script>
	<?php }
} else { ?>
	Content for non-logged in users goes here.
<?php } ?>

Hope this helps. :)

Posted: Thursday Nov 22nd, 2012 at 7:02 pm #32377
Leo Woer
Username: lewo

Ok – I’ll try this and let you know. Another thing which could be useful is if I can ask which page is open and then display content based on this, I am thinking about somthing like :

if page 175 is current page open
  then write this
Elseif page 176 is current page open
  then write this
else 
  write nothing

Would that be possible and if yes – can you tell me how I ask which page is the current page ?

Thanks
Leo

Posted: Friday Nov 23rd, 2012 at 12:31 pm #32426
Eduan
Username: Eduan
Moderator

Hello Leo,

This would be possible, but it’s outside s2Member, you gotta use WordPress functions to do this, check their codex: http://codex.wordpress.org/

You would of course use the s2Member conditionals, but you would use WordPress functions in order to check which post it is.

– Eduan

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