
Category Archives: Buddypress

Customize Client Admin dashboard
- Assign one user an “Editor” Role.
- Add capabilities “manage_options”, “list_users” and “delete users” using User Role Editor.
- Uninstall URE after making the changes. (the changes are permanent for this user)
- Add following to functions.php
// Remove some menus from Client Admin's Dashboard function remove_menus(){ if (current_user_can('manage_options') && !current_user_can('update_core')) { remove_menu_page( 'options-general.php' ); //Settings remove_menu_page( 'edit.php?post_type=ia_invites'); //Buddypress Invitations remove_menu_page ( 'tools.php' ); } } add_action( 'admin_menu', 'remove_menus' );
Prevent users from changing their email id and password in Buddypress
For demo Buddypress sites, you may want want to prevent users from ‘accidentally’ changing the email id and passwords of demo accounts.
Users can reset Email and Password from either the front-end or the backend (wp-admin).
To disable editing from the backend, put the following code in your child theme’s functions.php (Source: http://wordpress.stackexchange.com/a/53056)
//Disables certain fields (email, password) in WP Admin user profile page (profile.php) global $pagenow; if ( $pagenow == 'profile.php' ) { add_action( 'admin_footer', 'disable_userprofile_fields' ); } /** * Disables certain fields (email, password) in WP Admin edit user page (profile.php) */ function disable_userprofile_fields() { ?> <script> jQuery(document).ready( function($) { if ( $('input[name=email]').length ) { $('input[name=email]').attr("disabled", "disabled"); } if ( $('input[name=pass1]').length ) { $('input[name=pass1]').attr("disabled", "disabled"); } if ( $('input[name=pass2]').length ) { $('input[name=pass2]').attr("disabled", "disabled"); } }); </script> <?php }
To disable editing from the front-end, locate the file wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/members/single/settings/general.php
Import this file to wp-content/themes/[your-theme]/buddypress/members/single/general.php (keep the directory structure as described here)
Simply add a ‘readonly’ attribute to the input fields’ html. For example, change the line
<input type="text" name="email" id="email" value="<?php echo bp_get_displayed_user_email(); ?>" class="settings-input" />
to
<input readonly type="text" name="email" id="email" value="<?php echo bp_get_displayed_user_email(); ?>" class="settings-input" />
PS: The method described above is not foolproof – it does make it harder for the average user to edit the fields, but the readonly attribute can be overridden by using developer tools such as firebug. Look for alternate solutions if your life depends on it.
Group forum search for buddypress
This is Chris Mavricos’s solution extended to enable single forum search inside Buddypress groups.
Step 1. Create a blank file called form-search.php in your theme’s bbpress folder. Put the following code inside this file (your-theme/bbpress/form-search.php):
<?php /** * Search * * @package bbPress * @subpackage Theme */ $forum_id = bbp_get_forum_id(); ?> <form role="search" method="get" id="bbp-search-form" action="<?php bbp_search_url(); ?>"> <div> <label class="screen-reader-text hidden" for="bbp_search"><?php _e( 'Search for:', 'bbpress' ); ?></label> <input tabindex="<?php bbp_tab_index(); ?>" type="text" value="<?php echo esc_attr( bbp_get_search_terms() ); ?>" name="bbp_search" id="bbp_search" /> <?php if( $forum_id ): ?> <input class="button" type="hidden" name="bbp_search_forum_id" value="<?php echo $forum_id; ?>" /> <?php endif; ?> <input tabindex="<?php bbp_tab_index(); ?>" class="button" type="submit" id="bbp_search_submit" value="<?php esc_attr_e( 'Search', 'bbpress' ); ?>" /> </div> </form>
Step 2. Put the following code inside your theme’s functions.php:
/* * Search only a specific forum */ function my_bbp_filter_search_results( $r ){ //Get the submitted forum ID (from the hidden field added in step 1) $forum_id = sanitize_title_for_query( $_GET['bbp_search_forum_id'] ); //If the forum ID exits, filter the query if( $forum_id && is_numeric( $forum_id ) ){ $r['meta_query'] = array( array( 'key' => '_bbp_forum_id', 'value' => $forum_id, 'compare' => '=', ) ); $group_id = bbp_get_forum_group_ids( $forum_id ); if( groups_is_user_member( bp_loggedin_user_id(), $group_id[0] ) ) { function my_allow_all_forums () { return true; } add_filter( 'bbp_include_all_forums', 'my_allow_all_forums' ); } } return $r; } add_filter( 'bbp_after_has_search_results_parse_args' , 'my_bbp_filter_search_results' );
You should find a functional search box inside Buddypress group forums now.
Thanks to tobyhawkins for providing the additional code snippet.
Remove “Profile Updates” from Activity Stream Filter
remove_action( 'bp_activity_filter_options', 'xprofile_activity_filter_options' );