Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Forum user roles and moderator ability — BP 1.2-RC2 / WP 2.9.1


snark
Participant

@snark

I found this code that can be wrapped around anything to hide it from everyone but administrators or ediors:

<?php if ( current_user_can( ‘delete_others_posts’ ) ) { //only admins and editors can see this ?>

(Items to be hidden here)

<?php } ?>

To make it work specifically for hiding that “Create a Group” button, I made a new version of the default template’s groups –> index.php file in my child theme, replacing this:

<h3><?php _e( ‘Groups Directory’, ‘buddypress’ ) ?><?php if ( is_user_logged_in() ) : ?>  “><?php _e( ‘Create a Group’, ‘buddypress’ ) ?><?php endif; ?></h3>

With this:

<h3><?php _e( ‘Groups Directory’, ‘buddypress’ ) ?><?php if ( current_user_can( ‘delete_others_posts’ ) ) : //only admins and editors can see this ?>  “><?php _e( ‘Create a Group’, ‘buddypress’ ) ?><?php endif; ?></h3>

It worked like a charm! Now only Admins and Editors can create groups on my site.

Skip to toolbar