Page 1 of 1

Temporary Access Links

PostPosted: November 21st, 2011, 1:03 pm
by fx_keith
Hi, I'm trying to provide temporary access links S2member protected pages to outside users (reviewers, journalists, etc). I have posts that are restricted by category/user levels, but I would also like the ability to generate expiring links to those same pages.

I though I could solve it by tapping into the 'Specific Post/Page Access' functionality. Specifically 'c_ws_plugin__s2member_sp_access::sp_access_link_gen' to provide me with the expiring link. But since the posts are also under the user access restrictions, the links require the users to be logged in as well. I know the documentation warns about that, but I'd really like to get around it. Are there any other ways I can bypass the access restrictions in this scenario?

Re: Temporary Access Links

PostPosted: November 22nd, 2011, 6:10 pm
by Jason Caldwell
Thanks for the heads up on this thread.

It will be very difficult to avoid all aspects of s2Member's protection and Alternative View Restrictions in this regard. However, if you are generating links that point directly to the Permalinks for these Posts/Pages via Specific Post/Page Access, you might do something like this.

Create this directory and file:
/wp-content/mu-plugins/s2-hacks.php
Code: Select all
<?php

add_filter 
("ws_plugin__s2member_check_post_level_access_excluded", "my_s2_exclusions");
add_filter ("ws_plugin__s2member_check_page_level_access_excluded", "my_s2_exclusions");

/* Now build the function. */ function my_s2_exclusions ($s2_says = FALSE)
    {
        global $post; /* Global ```$post`` object reference. */
        /**/
        if (!empty ($post->ID) && c_ws_plugin__s2member_sp_access::sp_access ($post->ID, "read-only"))
            return /* Exclude it, because it's allowed by Specific Post/Page Restrictions. */ ($my_s2_says = true);
        /**/
        return /* Otherwise return whatever s2Member says. */ $s2_says;
    }
?>
* This provides for temporary exclusions of User Level Restrictions whenever a specific Post/Page ID is explicitly allowed via s2Member Specific Post/Page Access Restrictions. I think this is what you're after.

Re: Temporary Access Links

PostPosted: November 28th, 2011, 2:59 pm
by fx_keith
That's great Jason. Thanks.
Unfortunately, I'm getting a redirect to signup page before that action even fires. I have it rolled up into a plugin, so maybe it's an execution order type thing. I'm looking into what's causing the redirect right now.

Re: Temporary Access Links

PostPosted: November 28th, 2011, 4:30 pm
by fx_keith
My bad. I was using it on a post, not a page. Action should have been 'ws_plugin__s2member_check_post_level_access_excluded'. Thanks.