latest stable versions: v130513 (changelog)

s2Member® Forums

The Customers Forum is only for paying customers.
~ We also have a free/open Community Forum.

Troubleshooting Tips

Customer support for products by s2Member® is available only through your account at s2Member.com, which grants you access to our Customers Forum. We also have public Community Forum available to all site owners (no purchase required). For further details, please read our Support Policy, which includes a list of things that we will support, and also some things that we will NOT support. Please read this before posting.

We ask that you submit all pre-sale and/or technical support questions through the appropriate support forum at s2Member.com. If you are a paid customer, an s2Member® support representative will gladly address your question/concern within 24-48 hours; excluding all major holidays. Thank you!

For troubleshooting assistance, please read this article.

URI Restriction for BuddyPress profile

Home Forums Customers Forum URI Restriction for BuddyPress profile

This topic contains 8 replies, has 3 voices.
Last updated by  Richard Wells 11 months, 1 week ago.

Topic Author Topic
Posted: Tuesday May 22nd, 2012 @ 12:45 pm #14189
Richard Wells
s2Member® Pro (Paid Customer)
Paid Customer

I am trying to implement a URI restriction for BuddyPress profiles. I have tried /members/ but that restricts too much. I have tried /profile/ but that restricts too little. I want the Goldilocks option: show the list of members but not individual profile content.

Looking at the URL for the view I want to restrict the URI fragment would be, in effect, /members/username of displayed profile/. I have tried replacement codes like %%displayed_user_login%% but that does not work. Is there any way to do this?

List Of Topic Replies

Viewing 8 replies - 1 through 8 (of 8 total)
Author Replies
Author Replies
Posted: Wednesday May 23rd, 2012 @ 11:07 am #14333
Richard Wells
s2Member® Pro (Paid Customer)
Paid Customer

I think I have found a way to do this! But it involves a hack:

I have created my own custom Replacement Code %%displayed_username%% and added it in wp-content/plugins/s2member/includes/classes/ruris.inc.php:

$uris = (strlen ($displayed_username)) ? preg_replace ("/%%displayed_username%%/i", c_ws_plugin__s2member_utils_strings::esc_ds ($displayed_username), $uris) : $uris;

I extracted the value for $displayed_username from the URL of the page using $_SERVER["REQUEST_URI"].

$displayed_username = str_replace("/members/", "", $_SERVER["REQUEST_URI);
$slash = strpos($displayed_username, "/");
$displayed_username = substr_replace($displayed_username, "", $slash);

There must be a neater way to do this, eg using preg_match() but I spent ages trying with no luck!

  • This reply was modified 11 months, 3 weeks ago by  Richard Wells.
Posted: Thursday May 24th, 2012 @ 2:09 am #14396
Cristián
Official s2Member® Support Rep
Support Rep
HelpfulExperiencedCertified

Ah, I’m glad you could solve it. So it’s working for you now?

A preg_replace would have been better than the preg_match. You could also explode with the slashes and then put it back together.

Posted: Monday May 28th, 2012 @ 8:26 am #14809
Richard Wells
s2Member® Pro (Paid Customer)
Paid Customer

Yes, it does seem to work. Anyone can view /members/ but only chosen levels can view /members/username of displayed profile/.

I have put the edited contents of ruris.inc.php into /wp-content/mu-plugins/s2-hacks.php so it will not be overwritten when s2Member is updated.

Posted: Tuesday May 29th, 2012 @ 7:05 am #14869
Cristián
Official s2Member® Support Rep
Support Rep
HelpfulExperiencedCertified

Cool. :)

Posted: Monday Jun 4th, 2012 @ 5:41 am #15331
bob heyman
s2Member® Pro (Paid Customer)
Paid Customer

Hello

I am new to s2member hacks and php ..I am also looking for same kind of solution . i understand to added
$uris = (strlen ($displayed_username)) ? preg_replace (“/%%displayed_username%%/i”, c_ws_plugin__s2member_utils_strings::esc_ds ($displayed_username), $uris) : $uris;

into wp-content/plugins/s2member/includes/classes/ruris.inc.php but cam you please explain where do i put the rest of the code
$displayed_username = str_replace(“/members/”, “”, $_SERVER[“REQUEST_URI);
$slash = strpos($displayed_username, “/”);
$displayed_username = substr_replace($displayed_username, “”, $slash);

Please help me … Thanks in advance

Posted: Tuesday Jun 5th, 2012 @ 4:36 am #15431
bob heyman
s2Member® Pro (Paid Customer)
Paid Customer

OK .. i solved it my self .. I have one more query .. i need to redirect 0level users to upgrade membership page when they click on the any member on Member list ..

Can you help me on this

Posted: Tuesday Jun 5th, 2012 @ 7:57 pm #15592
Cristián
Official s2Member® Support Rep
Support Rep
HelpfulExperiencedCertified

Hi Bob.

You’d have to find a string that matches the user profile URLs and add it to the URI restriction for Level 1.

Posted: Tuesday Jun 12th, 2012 @ 12:00 pm #16262
Richard Wells
s2Member® Pro (Paid Customer)
Paid Customer

Bob

Confusingly the second bit of code should go before the first in order to set the value for $displayed_username (eg line 101 in my version of ruris.inc.php).

I have then put /members/%%displayed_username%%/ in the box for “URIs That Require Level #0 Or Higher:” in s2Member>Restriction Options>URI Restrictions.

This means when someone clicks a Member in the Member list they are redirected to the upgrade page.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘URI Restriction for BuddyPress profile’ is closed to new replies.

If you're a paying customer, please use our Customers Forum. We also have a public Community Forum available to all site owners (no purchase required). You can register here (it's free). For further details, please read through our Support Policy.