URI Conditionals Challenge
Posted: 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...
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...
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...