Redirect if user does not have the correct ccap

Forums General Redirect if user does not have the correct ccap

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #371
    Carole Asselin
    Participant

    As far as i know (and i might be wrong too), if a page is restricted by a ccap, if the user does not have that ccap, he gets redirected to the Membership option page, by default.

    Is there a way to redirect to a specific page where the user could purchase the access to this particular page (or set of pages)?

    Here is the scenario:
    I have Course A that includes dripping content where many pages are restricted.
    I also have a nice, elaborate sale page for that Course.

    Right now, if someone tries to access one of the restricted pages, he gets redirected to the Membership option page, where i have also other courses listed, so the user will not see the sale page that relates to the particular page/course he wanted to access since he will also see info on Course B and Course C, etc.

    Is there a way to currently redirect unauthorized visitors to a specific page instead of the default Membership option page?
    If it is not possible, maybe a suggestion to add a link to that specific page under the “Require Custom Capabilities?” in the s2Member box?

    If it is not possible yet, maybe i can add that suggestion in the Github forum?

    #375

    Well, you could customize the behavior in different ways…

    You can change the Membership Options Page’s content with conditionals, using the MOP Vars. WP Admin -> s2Member -> Scripting -> Membership Options Page Variables

    Or, you could try a must-use plugin that checks if the required access is the ccap you’re talking about, and redirect the person to another page instead. Or do the redirection in the page with a conditional and a JavaScript redirection.

    Maybe somthing like this: In /wp-content/mu-plugins/s2mop-redir.php

    <?php
    if (!empty($_REQUEST['_s2member_vars']))
       @list($restriction_type, $requirement_type, $requirement_type_value, $seeking_type, $seeking_type_value, $seeking_uri)
            = explode("..", stripslashes((string)$_REQUEST["_s2member_vars"]));
    
    if (!empty($seeking_value) && $seeking_value == 'yourccaphere' ) {
       header('Location: http://www.yoursite.com/yourccapsalespage');
       exit;
    }

    Not tested, but I hope it helps. 🙂

    #377
    Carole Asselin
    Participant

    That might work. I`ll try and report back.

    But if it is not a native function of s2M, i think it would be a great feature to add, directly in the dashboard. Don’t you think?

    #378
    Carole Asselin
    Participant

    I am not good enough in php syntax but as it, it is not working. Shouldn’t there be a closing tag or something at the end?

    #380

    No, the PHP closing tag is not required there.

    Hmm… What is the ccap you’re using for that? Can I have a link to a page protected with it to see what the MOP vars are when redirected?

    Thanks!

    #381
    Carole Asselin
    Participant

    Here is the code i am using

    <?php
    if (!empty($_REQUEST['_s2member_vars']))
       @list($restriction_type, $requirement_type, $requirement_type_value, $seeking_type, $seeking_type_value, $seeking_uri)
            = explode("..", stripslashes((string)$_REQUEST["_s2member_vars"]));
    
    if (!empty($seeking_value) && $seeking_value == 'element' ) {
       header('Location: http://scrapbookcampus.com/creative-scrap/creative-scrap-register/');
       exit;
    }
    

    Here is one page that you need the ‘element’ ccap to access:
    http://scrapbookcampus.com/element-creation-index/folded-edge/

    and the sale page is obviously this one:
    http://scrapbookcampus.com/creative-scrap/creative-scrap-register/

    #386

    Thanks!

    Okay, I wrote a new simpler one, and tested it to confirm it works.
    http://s2member.net/?_s2member_vars=ccap..ccap..element..page..4286

    <?php
    if (!empty($_REQUEST['_s2member_vars']) && strpos($_REQUEST['_s2member_vars'], 'ccap..ccap..element') !== false) {
       header('Location: http://scrapbookcampus.com/creative-scrap/creative-scrap-register/');
       exit;
    }

    🙂

    #387
    Carole Asselin
    Participant

    Great! It works exactly as i was hoping. Now, if it can be integrated as a native feature, everyone will be able to use it easily. 🙂

    #395

    Great! 😀

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.