PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Conditional redirect to another page

s2Member Plugin. A Membership plugin for WordPress®.

Re: Conditional redirect to another page

Postby cassel » August 14th, 2011, 12:47 pm

I am a little our of breath, but it is all good!

Do you know if there is any central place to list various codes like this on this forum? I am sure others would love to use something like that.
User avatar
cassel
Experienced User
Experienced User
 
Posts: 442
Joined: February 17, 2011

Re: Conditional redirect to another page

Postby Bruce C » August 14th, 2011, 12:55 pm

If someone searches for it, they will find this post.

Other than that, nope.
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: Conditional redirect to another page

Postby cassel » September 9th, 2011, 8:58 pm

This code works perfectly for the initial redirect i set up, but today, i am applying the exact same code with a different set of pages, and it does not seem to want to behave the same way.

I have the sales page here: http://scrapbookcampus.com/register-ele ... -with-psp/ (for non registered members) and the index page here: http://scrapbookcampus.com/element-creation-index/ (for the registered members).

On the sales page, i put this:
Code: Select all
<?php if (current_user_can('access_s2member_ccap_element') && !current_user_can('administrator')){ ?><script type="text/javascript">window.location = http://scrapbookcampus.com/element-creation-index/';</script><?php } else {?><?php } ?>


and on the index page, i put this:
Code: Select all
<?php if (!current_user_can('access_s2member_ccap_element') && !current_user_can('administrator')){ ?><script type="text/javascript">window.location = 'http://scrapbookcampus.com/register-element-tutorials-with-psp/';</script><?php } else {?><?php } ?>


If i am a logged in member without proper ccaps access, i get redirected from the index to the registration page.
If i am logged in as a registered member with access to the ccaps "element" i am NOT redirected from the registration page to the Index page.
Am i missing something? Is there a little detail missing in the code?
User avatar
cassel
Experienced User
Experienced User
 
Posts: 442
Joined: February 17, 2011

Re: Conditional redirect to another page

Postby Bruce C » September 9th, 2011, 10:51 pm

It took me a bit, but I found it.

You're missing the beginning quote on your first URL


This fixes it:

Code: Select all
    <?php if (current_user_can('access_s2member_ccap_element') && !current_user_can('administrator')){ ?><script type="text/javascript">window.location = 'http://scrapbookcampus.com/element-creation-index/';</script><?php } else {?><?php } ?>
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: Conditional redirect to another page

Postby cassel » September 10th, 2011, 3:47 am

Thanks for the correction, but it still is not redirecting :( Gremlins???
User avatar
cassel
Experienced User
Experienced User
 
Posts: 442
Joined: February 17, 2011

Re: Conditional redirect to another page

Postby cassel » September 10th, 2011, 5:18 pm

Must have been gremlins. I copied the same code you gave me and it never worked. So i tried copying the old code for the other page and see if the code itself worked. It did. Then, i changed ONLY the ccaps, and it directed to the correct page (for the old code). Then, i edited the target URL and it worked. Why it was not working before? Mystery. But it works fine now. Woohoo!!
User avatar
cassel
Experienced User
Experienced User
 
Posts: 442
Joined: February 17, 2011

Re: Conditional redirect to another page

Postby Bruce C » September 10th, 2011, 8:11 pm

Cool.
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Previous

Return to s2Member Plugin

Who is online

Users browsing this forum: Google [Bot] and 2 guests

cron