Tag Info

Hot answers tagged

2

There is no tax_query parameter for the WP_User_Query class. Since you've tagged the question with user-meta I can only assume you store the ID (or even the term name itself?) of a particular shop-category term as a user meta entry. In this case you would need something like this: // The 'WP_User_Query' arguments array $args = array( 'role' ...


1

Notice how it is singular? Comment, not comments? This capability is not designed to check if user can edit any arbitrary comment out there. It can only check if user can edit one specific comment and correct way to call it is current_user_can( 'edit_comment', $comment_id ). Unfortunately second argument is missing from current_user_can() function ...


1

How about remove_meta_box( $id, $page, $context );? https://codex.wordpress.org/Function_Reference/remove_meta_box This will remove the Publish meta box which contains the save button... function disable_save() { if( !current_user_can( 'edit_post' ) ) { // Or whatever check you need to make remove_meta_box( 'submitdiv', ...


1

You can check for specific user role using following code - if (is_user_logged_in() && current_user_can('administrator')) {} The function current_user_can() takes role name as parameter. For more info - https://codex.wordpress.org/Function_Reference/current_user_can/


1

Make sure your level ids are 1, 2, and 3, etc. //For check level id 1. if(pmpro_hasMembershipLevel(1, $user->ID)) You can check for get membership level of any user from documentation. PMPro includes a built-in function allowing you to require membership or require a specific membership level.


1

I got it to work as follows -- in mu-plugins directory, my superAdmin.php script looks like this: <?php function check_for_superAdmin($user_login, $user) { $current_user = get_userdatabylogin($user_login); if ( is_super_admin( $current_user->ID ) ) { // do these things } else { // do other things } } add_action( 'wp_login', ...


1

You can use wp_get_current_user() function to get current logged in user's role //Remove admin menu items if not admin function remove_admin_bar_links() { global $wp_admin_bar, $current_user; $user = wp_get_current_user(); if ( in_array( 'author', (array) $user->roles ) ) { $wp_admin_bar->remove_menu('updates'); // ...



Only top voted, non community-wiki answers of a minimum length are eligible