Update: bbPress 2.4 does not fix the bug!
bp_is_profile is used to test if its a profile page. try that in a conditional.
@henrywright-1, @shanebp
Thank you very much. The code worked nicely, removing both the button and the functionality.
rt.
You probably ought to have migrated your bbPress group forums to the standalone plugin.
I just read the new Codex on child themes- so it should work with any theme- (answered my own question)
Thank you for putting up with another newbie guys 🙂
Best
Thanks for the feedback
I think I understand now- the profile page has activity on it so it’s not possible to do what that way, and it’s linked to the member page because that is showing profiles.
I could hide things from members with template overrides as you suggest- but I’m not sure if it will work with my theme being a child theme of Twenty Thirteen. If I put the BuddyPress override template files in my child theme will it work?
Thanks
So you want to block
yoursite.com/members/
and
yoursite.com/activity/
from users who aren’t admins or editors ?
But allow everyone to view
yoursite.com/members/my-profile?
Then you might try putting a current_user_can conditional directly in the over-ride templates for those two pages.
[there surely is a way to write a function to do this, but it escapes me at the moment]
Hi @shanebp and @henrywright-1
Thanks for your help- I agree with Shanebp that his function does the same thing and is simpler, however I still have the same problem in that it stops access to the members PROFILE page.
I think this must be a problem with BuddyPress though- maybe it’s a bug?
Anyway thank you both for helping with the functions I think it will be handy for other things until I sort that problem out.
Perhaps a simpler way, given that she wants to check for both admin and editor, is to test against a cap that both admin and editor have.
Something like: `function bp_my_restrict() {
if ( !current_user_can(‘edit_posts’) ) {
if ( bp_is_current_component(‘members’) || bp_is_current_component(‘activity’) ) {
bp_core_redirect( home_url() );
}
}
}
add_action(‘wp’,’bp_my_restrict’);`
Hi @mossyoak
I’ve run a few tests and made some slight changes to that code. Try this
function bp_my_restrict() {
$user_id = bp_loggedin_user_id();
$user = new WP_User( $user_id );
if ( ( $user->roles[0] != 'administrator' ) ) {
if ( bp_is_current_component('members') || bp_is_current_component('activity') ) {
wp_redirect( home_url() );
exit();
}
}
}
add_action('wp','bp_my_restrict');
Hi
Thanks for your help again
I tried your function
function bp_my_restrict() {
global $bp;
$user_id = bp_loggedin_user_id();
$user = new WP_User( $user_id );
if ( bp_is_current_component('members') || bp_is_current_component('activity') ) {
if ( ( $user->roles[0] != 'administrator' ) ) {
wp_redirect( $bp->loggedin_user->domain );
exit();
}
}
}
add_action('wp','bp_my_restrict');
But it gave a redirect loop error- I think it is because these conditionals are stopping the profile page being accessed for users lower than admin so trying to redirect to it is just looping.
I changed the redirect to the home page which stopped the constant loop- but users who are not admin can still not access the profile page- these conditionals are stopping that which is a bit odd.
// BuddyPress restrict activity and members page
function bp_my_restrict() {
global $bp;
$user_id = bp_loggedin_user_id();
$user = new WP_User( $user_id );
if ( bp_is_current_component('members') || bp_is_current_component('activity') ) {
if ( ( $user->roles[0] != 'administrator' ) ) {
wp_redirect( home_url() ); exit;
}
}
}
add_action('wp','bp_my_restrict');
Thank you for your help.
Just read through your original question. The code snippet you’d want to add to your theme’s functions.php is something like this:
function bp_my_restrict() {
global $bp;
$user_id = bp_loggedin_user_id();
$user = new WP_User( $user_id );
if ( bp_is_current_component('members') || bp_is_current_component('activity') ) {
if ( ( $user->roles[0] != 'administrator' ) ) {
wp_redirect( $bp->loggedin_user->domain );
exit();
}
}
}
add_action('wp','bp_my_restrict');
Try this
<?php
$user_id = bp_loggedin_user_id();
$user = new WP_User( $user_id );
if ( $user->roles[0] != 'administrator' ) {
// your code
}
?>
There is still a problem though in that if I do this it stops any member who is not an admin level user accessing their profile page. Not sure why it should affect that- tried with just the activity conditional and it stops profile page access as well.
elseif (bp_is_current_component( 'members' ) || bp_is_current_component( 'activity' )) :
get_header('restrict');
I’m using a header-restrict.php which redirects them with this redirect at the very top of it:
<?php if(!current_user_can('delete_others_pages')) { wp_redirect( home_url() ); exit; } ?>
Any ideas?
I disabled the plugin “simple chat” and it worked again!
Thanks for your help Henry- I tried the is_page conditional but it does not work with the BuddyPress Pages.
So I tried bp_is_Page which worked, but was depecated.
Then I tried
bp_is_current_component( 'activity' ) || bp_is_current_component( 'members' )
and they work for what I want.
Thanks for your feedback it helped a lot 🙂
Chris
You could use the WordPress conditional is_page() to check if the user is on the activity or members page:
if ( is_page('members') || is_page('activity') ) {
} else {
}
Note: I’m assuming you haven’t changed the default slugs
Hi there
I am working on a personal project making a private client portal with BuddyPress.
I’ve made a child theme for Twenty Thirteen that does this- thanks to the new update to BuddyPress that lets any theme use buddypress out of the box.
It uses page templates to assign whether pages are private or public. If they are private it directs non logged in users to the login page.
I have multiple headers for different levels of privacy that are assigned to different page templates.
I just wondered if anyone could help me solve a problem.
I wanted to make it so that the members page and general activity page’s could be made so that only an admin or editor could view them but page templates don’t seem to work with these pages.
I’ve used conditionals for certain areas of BuddyPress to force certain headers: e.g.
elseif (bp_is_user_profile() || bp_is_user_activity() || bp_is_user_groups() || bp_is_user_blogs() || bp_is_user_friends() || bp_is_user_messages() || bp_is_user_forums() ):
get_header('restrict-profile');
I think that would work with the activity and members page but I’m not sure what the conditionals are for those.
Please could someone help?
Thanks
Is there anyone to help on this ?
I get a 404 error while requesting to join a private group in buddypress 1.8.1.
Could you please check this?
I have Multisite WP 3.6.
Hey there,
When navigating to the “Discussion Forums” WordPress-Page (BP Groups Forum used) only WordPress Admins can see the threads for Private Group Forums they are members in. Normal Users only see the threads from Public Groups, but not from Private Groups they are a part of. That doesn’t seem right.
This issue was discussed at length in this topic (relating to BP 1.5.1), and it looked like a solution/patch was eminent, but then nothing. Then the TracTicket for this item was closed with a “wontfix” citing that the functionality was included in BBPRESS 2.
So where does that leave users of legacy groups? Any insight would be greatly appreciated.
BUDDYPRESS 1.8.1
WPRESS 3.6
Hi folks,
Are their any coding wizards out there who can tell me how to stop “Private” groups from showing in the sidebar (in the BP default theme)? I know hidden groups are not shown, but as default, public and private groups do show up.
Many thanks!
Hi,
plugins:
WP 3.6
members
buddypress
buddypressDocs
I would like to limit the access to new user when he goes to activation page !
When someone goes to activation page, he can fill his own form and display directly on the members list page, I don’t want that !
How could I limit that ? Maybe if we only the admin give access or private page with password ?
thank you for your attention
I’ve not seen this. How about adding a voting option for BP Groups.
And I’m not talking about the Favorite or FB Like Button, but a bonafied capacity to do voting – or for some people “Make Community Decisions” democratically or in modified versions.
I’m of course interested in the modified version since a lot of activist communities seek to gain consensus vs. a mere 50% + 1 vote.
Such an addition would look just like a Forum or the BP Docs with its own menu. Each member of the group could go there and do the following:
Phase I:
Participate in either with real time chat or with comments in the creation of the wording of the proposed issue to be voted on. This section would also have the capacity to schedule a vote and announce it to the group. This module would also be able to identify several different types of votes that could take place from selecting a person for a position, a straw vote or informal poll on an issue, the real vote or an appeal/call for revote.
Phase II:
The vote Module
Of course, this would be where a variety of formats would be defined by the phase I type of vote and then allow each user to enter their own voting booth and make a decision.
Phase III
Vote tabulation and archiving
This of course would be how each individual vote is setup, much like a standard post with the ability to save comments (discussion threads) that could be closed by the admin but all of it could be held as a single event in the database. Of course just as people have elections, the archiving cycle should also be able to frame votes by time or far more important for small communities by subject. So that a group could interweave the voting plugin/option could then be woven directly into the groups bylaws. By this, I’m saying that each voting event then be given a URL so that it could then be directly linked to a public or private document like the groups internal bylaws if they want.
You do this, and you’ve taken the next step in really making a community that can make online decisions!