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®.

Conditional redirect to another page

Postby cassel » August 7th, 2011, 7:03 pm

I am not sure if i am looking at it the wrong way or if it needs something i dont know, but i am stuck.

I am making a direct link from my main page to a SALES page. Here is the sales page:
http://scrapbookcampus.com/register-bas ... -with-psp/

I am sneaky, as i made that page ESPECIALLY for a sales pitch, with no navigation, no breadcrumbs, basically nowhere to go but BUY or back. :lol:

However, if i have a registered member who clicks on the same link on the main page, thinking it is going to bring him to his accessible set of links for the course, i would like that particular member to be redirected to the correct page, instead of a sales page for which he already subsribed.

One way would have been to make the page doubled: one conditional to show the sales pitch, and one conditional to show the links instead, but i want the registered members to have the navigation, the breadcrumbs, and everything else so i would prefer to direct him to the correct page for registered member. Is there a simple way to do that?
User avatar
cassel
Experienced User
Experienced User
 
Posts: 442
Joined: February 17, 2011

Re: Conditional redirect to another page

Postby Bruce C » August 7th, 2011, 7:35 pm

You could do a redirect based on the level of the member.

Are you programming the theme itself? In that case, you can use the PHP redirect which is at http://php.net/manual/en/function.http-redirect.php

In which case you could just use the current_user_can() function as found in s2Member -> API/Scripting -> Custom Capabilities (Packages). Or, if you just want to put it directly into the page, a JavaScript redirect would work just fine also.

I'm assuming that's what you mean by

so i would prefer to direct him to the correct page for registered member


Does that help?
~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 » August 7th, 2011, 7:52 pm

I am not sure what the difference would be but here what i can answer:

- i am not programming the theme. I am using Headway Theme
- using ccaps conditional would work (as far as i know) except that it would only affect the content and not the rest of the page (like the navigation, breadcrumbs, footer)
- a javascript redirect... what is that? In fact, the reason i love Headway theme, is because i dont know about programming or coding css, html, or java, so if it is possible to suggest a snippet that i can copy and edit, it would be appreciated, if that simple redirect to a DIFFERENT page is possible.
User avatar
cassel
Experienced User
Experienced User
 
Posts: 442
Joined: February 17, 2011

Re: Conditional redirect to another page

Postby Bruce C » August 7th, 2011, 8:27 pm

snippet that i can copy and edit, it would be appreciated, if that simple redirect to a DIFFERENT page is possible.


Yea, I can do that.

Code: Select all
<head>
<?php
if(current_user_can('access_s2member_level1'))
{
   header( 'Location: http://google.com/' ) ;
}
?>
</head>

If you put that code at the top of your page (don't let ANYTHING else be on top of it) it will redirect to http://google.com/ if the viewer is a s2Member level 1 or higher. Just change Google to the correct location.
~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 » August 7th, 2011, 8:30 pm

Is there a shortcode equivalent?
User avatar
cassel
Experienced User
Experienced User
 
Posts: 442
Joined: February 17, 2011

Re: Conditional redirect to another page

Postby Bruce C » August 7th, 2011, 8:38 pm

Oh yeah, there sure is.


Code: Select all
<head>
[s2If current_user_can(access_s2member_level1)]
<?php header( 'Location: http://google.com/' ) ; ?>
[/_s2if]
</head>
~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 » August 7th, 2011, 8:51 pm

Hum... does not seem to work. Here is what i put:
Code: Select all
<head>
[s2If current_user_can("access_s2member_ccap_basic")]<?php header( 'Location: http://scrapbookcampus.com/basic-tutorials-for-scrapbooking-with-paintshop-pro/' ) ; ?>
[/_s2if]
</head>

The starting link is in the middle box (turquoise).
It sends a non registered student to this page:
http://scrapbookcampus.com/register-bas ... -with-psp/

And it SHOULD send a registered student with the proper ccaps to here:
http://scrapbookcampus.com/basic-tutori ... tshop-pro/

I put that code on top of the leaf for the page for NON-students to send the students to the right page. Maybe i put it in the right place.
User avatar
cassel
Experienced User
Experienced User
 
Posts: 442
Joined: February 17, 2011

Re: Conditional redirect to another page

Postby Bruce C » August 7th, 2011, 9:00 pm

I tried out that code on my page, is it not doing anything for you?

Keep in mind that that code should redirect people that ARE registered from http://scrapbookcampus.com/register-bas ... -with-psp/ to http://scrapbookcampus.com/basic-tutori ... tshop-pro/.

Did you put the code on http://scrapbookcampus.com/register-bas ... -with-psp/ , then try to view it both as an admin, and as a non-user?

Edit:

BTW-
The code goes into the link's page, not the link itself, I just realized I did not clarify that.
~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 » August 7th, 2011, 9:09 pm

Yes, i put it there, and i tried to check that link as an admin (i didn't try as not logged in since it would not need a redirect), and as an admin, i am not redirected. Should i be?
User avatar
cassel
Experienced User
Experienced User
 
Posts: 442
Joined: February 17, 2011

Re: Conditional redirect to another page

Postby Bruce C » August 7th, 2011, 9:11 pm

Do you have a plugin installed for PHP Execution? The code will not work without that.
~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 » August 7th, 2011, 9:17 pm

Oh... maybe not. What plugin should i get? (there are always so many)
User avatar
cassel
Experienced User
Experienced User
 
Posts: 442
Joined: February 17, 2011

Re: Conditional redirect to another page

Postby Bruce C » August 7th, 2011, 9:17 pm

Exec-PHP is one that I know works well.
~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 » August 7th, 2011, 10:03 pm

I will recheck later. I was asking for another information on another forum (about the theme) and the person said she could not see it because she was redirected to another page. I guess it might just be working, but i should only work on one thing at the time!

Thanks
User avatar
cassel
Experienced User
Experienced User
 
Posts: 442
Joined: February 17, 2011

Re: Conditional redirect to another page

Postby Bruce C » August 7th, 2011, 10:18 pm

Hope she's right!
:D
~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 » August 8th, 2011, 7:48 am

OK i might be facing a big challenge and i am not sure where to turn: whether s2Member can help me, or the theme support can help me, so i will be asking both places:

I integrated the code you suggested and it didnt work at first, but then, i installed Exec-PHP as you suggested. Initially, i didn`t see anything different so i figured i would come back to it later. At the same time, i was asking something in the Theme forum about some coding and i was refering them to my test-page where i was getting odd colors. They replied that clicking on the test page link was automatically redirecting them to the page i wanted to use for students (as mentioned above). I had used the redirect in one leaf so i figured i could desactive Exec-PHP, since it seemed to start working when it got installed. However, i am stuck now: whether it is as admin or logged out, i cannot access the test page anymore, either directly, or in the Visual editor for Headway Theme. Oddly enough, the redirect was supposed to be only for registered members with the right ccaps, but now, even as a logged out visitor, i cannot see it.

Can you see this page: http://scrapbookcampus.com/test-page ? or does it redirect you?

Any idea how to remove or desactivate the redirect so i can keep testing other things? It is like i locked myself out.
User avatar
cassel
Experienced User
Experienced User
 
Posts: 442
Joined: February 17, 2011

Re: Conditional redirect to another page

Postby Bruce C » August 8th, 2011, 10:43 am

Yes, it redirects me.
You cannot access the page through the Dashboard?
~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 » August 8th, 2011, 10:58 am

Not the way i know. I can access the page, but the text and the code are inside a leaf, and as far as i know, only accessible through the Visual Editor of Headway Theme. I am waiting on them to see if there is a backdoor that i dont know about :(

If nothing else, i will have to delete the page completely and start that from scratch. However, if i manage to do that, i am worried that i will lock myself out again, when i put that redirect into the live site for the live page without any way around. I guess, i could then try to enter all that into the page from the dashboard and see if it would look the same. Not sure, but worth a try (when i get home tonight)

I thought that desactivating the Exec-PHP would cancel the code i had just added. Any other code can be added to cancel the previous one??? (i am not a programmer, just someone with wierd ideas)
User avatar
cassel
Experienced User
Experienced User
 
Posts: 442
Joined: February 17, 2011

Re: Conditional redirect to another page

Postby Bruce C » August 8th, 2011, 11:15 am

deactivating Exec-PHP SHOULD stop the code. However, I'm not experienced with the Headway Theme. Do you have a Caching plugin installed? If you do, try clearing the cache.
~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 » August 8th, 2011, 11:26 am

Dont remember seeing a caching plugin in my list :(
User avatar
cassel
Experienced User
Experienced User
 
Posts: 442
Joined: February 17, 2011

Re: Conditional redirect to another page

Postby Bruce C » August 8th, 2011, 11:37 am

Okay, this is my fault, I forgot to add a else{} part. The code will just always redirect without that. Sorry, I'm I was focused on the redirect part, and forgot that.

Try to access the page in dashboard, then just add
Code: Select all
[s2If !current_user_can(access_s2member_ccap_basic)]
[/s2If]
~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 » August 8th, 2011, 11:43 am

Oh... Now, i just have to find a way to GET to the code to add that segment. Otherwise, i will have to start from scratch.

On the same topic, will that whole redirect snippet need to be on a complete page? I am thinking that i have used conditionals with different leafs in Headway (for different content), but it never included <head> part. Not sure if i can have that <head> on more than one leaf on a single page. ???
User avatar
cassel
Experienced User
Experienced User
 
Posts: 442
Joined: February 17, 2011

Re: Conditional redirect to another page

Postby Bruce C » August 8th, 2011, 11:48 am

I'm not clear on the concept of "leafs" but I'm guessing there wouldn't be a problem as <head> is just an html tag for the top of the page.
~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 » August 8th, 2011, 11:55 am

Leafs are individual boxes with content in each (some leaf have content extracted from page or posts, some will have html, some will hold widgets, some will hold only text, etc.). If <head> is related to a "page" it might be a "problem" since there is no content placed outside a "leaf" and none of them has a <head> tag.
User avatar
cassel
Experienced User
Experienced User
 
Posts: 442
Joined: February 17, 2011

Re: Conditional redirect to another page

Postby cassel » August 8th, 2011, 12:08 pm

Oh and btw, if it is your fault, it means you are the one who will have to squeeze though the basement window and come to unlock the door while i wait on the front porch! :lol:
User avatar
cassel
Experienced User
Experienced User
 
Posts: 442
Joined: February 17, 2011

Re: Conditional redirect to another page

Postby Bruce C » August 9th, 2011, 9:33 pm

Did you ever get this resolved?
~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

Next

Return to s2Member Plugin

Who is online

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

cron