Replies
Hi Dandy,
Please try the following code. I have created role using WP Role Editor and test.
function buddydev_remove_unwanted_menu() { global $wp_admin_bar; $user = wp_get_current_user(); $remove = false; // teacher, principal your role id if ( in_array( 'teacher', (array) $user->roles ) ) { $remove = true; } elseif ( in_array( 'principal', (array) $user->roles ) ) { $remove = true; } if ( $remove ) { $node_ids = array( 'my-account-xprofile-edit', 'my-account-xprofile-change-avatar', 'my-account-xprofile-change-cover-image' ); foreach( $node_ids as $id ) { $wp_admin_bar->remove_node( $id ); } } } add_action( 'wp_before_admin_bar_render', 'buddydev_remove_unwanted_menu' );Let me know if It is working for you or not.
Thank You
RaviHi Christian,
Sure, I will looking into and will update you by Monday.
Thank You
RaviHi Phillippe,
File location is in WordPress Plugin directory ‘mediapress/assets/css/mpp-core.css’. In this file you need to modify the following class
.mpp-lightbox-content .mpp-lightbox-media-container .mpp-lightbox-activity-containerThank You
RaviHi Dandy,
Thank you for the acknowledgement that You are using User Role Editor to create user role teacher or principal. I thought teacher and principal are BuddyPress Member type. I will post here the new code.
Thank You
RaviHi Dandy,
There is problem with your code ‘current_user_can’ is a WordPress function and works only with WordPress Roles and Capabilities. Please try the following code
function buddydev_remove_unwanted_menu() { if( ! is_user_logged_in() || ! function_exists( 'buddypress' ) ) { return; } global $wp_admin_bar; $is_teacher = bp_has_member_type( bp_loggedin_user_id(), 'teacher' ); $is_principal = bp_has_member_type( bp_loggedin_user_id(), 'principal' ); if ( $is_teacher || $is_principal ) { // place the node id you want to hide $node_ids = array( 'my-account-xprofile-edit', 'my-account-xprofile-change-avatar', 'my-account-xprofile-change-cover-image' ); foreach( $node_ids as $id ) { $wp_admin_bar->remove_node( $id ); } } } add_action( 'wp_before_admin_bar_render', 'buddydev_remove_unwanted_menu' );Hi Dandy,
Can You please share the code block that you are using?. I have tested this code on my local server and It is working for me.
Thank You
RaviHi Dandy,
Yes, it can be done to hide and show these items based on user role or capabilities. Please take a look the following url for WordPress User role and capability.
https://codex.wordpress.org/Roles_and_Capabilities
function buddydev_remove_unwanted_menu() { global $wp_admin_bar; /** * * either you can pass the capability or the user role like * current_user_can('edit_posts') with user capability * current_user_can('author') with user role * **/ if ( current_user_can('edit_posts') ) { // place the node id you want to hide $node_ids = array( 'my-account-xprofile-edit', 'my-account-xprofile-change-avatar', 'my-account-xprofile-change-cover-image' ); foreach( $node_ids as $id ) { $wp_admin_bar->remove_node( $id ); } } } add_action( 'wp_before_admin_bar_render', 'buddydev_remove_unwanted_menu' );Please let me know if it works for you or not.
Thank You
RaviHi Tammy,
I have fixed this issue. Please download the latest code from the following url
https://github.com/buddydev/bp-extended-user-groups-widget
and Let me know if it works for you or not.
Thank You
Ravi- Ravi on May 31, 2016 at 3:55 pm in reply to: [Resolved] BP Auto Activate Autologin Redirect To Profile On Signup #4050
Hi Christian,
No Worries, We have already tested.
Thank You
Ravi