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™

URI Conditionals Challenge

s2Member Plugin. A Membership plugin for WordPress®.

URI Conditionals Challenge

Postby startasocialnetwork » December 6th, 2010, 1:09 pm

Hi,

I'm working with s2Member Pro + BuddyPress, all most current versions.

I'm using URI Conditionals to restrict access to the BuddyPress feature "Activity" as per:
viewtopic.php?f=4&t=684&p=4894#p4894

...and it's working as expected.

The one NOT working is trying to restrict access to message a specific user (in this case "dana") as in "/messages/compose/?r=dana*" which is part of the URI that shows when clicking the "Send a Message" button in BuddyPress.

That same fragment DOES work under the URI Access Restrictions tied to Membership Access Levels under "General Options," but not as an advanced conditional in the functions.php file.

I assume it has to do with the ? in the URI?

Code from functions.php below...

Code: Select all
    <?php
    add_action ("template_redirect", "my_custom_capabilities", 1);
    function my_custom_capabilities ()
        {
            if (fnmatch ("/activity*", $_SERVER["REQUEST_URI"]) && !current_user_can ("access_s2member_ccap_activity"))
                {
                    header ("Location: " . S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL);
                    exit ();
                }
            else if (fnmatch ("/messages/compose/?r=dana*", $_SERVER["REQUEST_URI"]) && !current_user_can ("access_s2member_ccap_email"))
                {
                    header ("Location: " . S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL);
                    exit ();
                }
        }
    ?>


Any suggestions appreciated!

NOTE: I can't use the URI Access Restrictions tied to Membership Access Levels under "General Options," as I need more flexibility than just a handful of membership levels...
User avatar
startasocialnetwork
Registered User
Registered User
 
Posts: 23
Joined: October 8, 2010
Location: Vancouver, BC

Return to s2Member Plugin

Who is online

Users browsing this forum: Exabot [Bot] and 1 guest

cron