Restrict Users to Only Edit Media Owned by Users in Their Role
Restrict Users to Only Edit Media Owned by Users in Their Role
Restrict Users to Only Edit Media Owned by Users in Their Role
Try this to get you started. This creates a shortcode [alldevelopers] that displays a list of all developers. Pretty basic but can be heavily extended and duplicted. (Not tested) add_shortcode( ‘alldevelopers’, ‘show_all_developers’ ); function show_all_developers(){ $users = get_users( [ ‘role__in’ => [ ‘developers’ ] ] ); foreach ( $users as $user ) { echo $user->first_name … Read more
I found the solution: Within the https://wordpress.org/plugins/user-role-editor/ module, just check the option “Publish Posts” for the “Author” role…
You can check the current user role in the same action and apply “display none” for that specific user role $user = wp_get_current_user(); if ( in_array( ‘author’, (array) $user->roles ) ) { //The user has the “author” role }
To query posts with more than one author ID, you can use author__in parameter. This makes posts from chosen authors visible (read only) for the current user. add_filter(‘pre_get_posts’, ‘posts_for_current_author’); function posts_for_current_author($query) { if ( $query->is_admin && ‘edit.php’ === $GLOBALS[‘pagenow’] && ! current_user_can( ‘edit_others_posts’ ) ) { $query->set(‘author__in’, array(get_current_user_id(), 1, 2, 3) ); // add 1 … Read more
insert this code in your theme functions.php and use this shortcode [users_count_bro] to display where you want function total_count_bro() { $out=””; $user_count_data = count_users(); $avail_roles = $user_count_data[‘avail_roles’]; foreach ( $avail_roles as $role_key => $role_count ) { $out .= $role_key.’:’.$role_count.'<br/>’; } return $out; } add_shortcode( ‘users_count_bro’, ‘total_count_bro’ );
Adding this as an answer here for reference for anyone searching for WP_User_Query stuff: As per the docs The search field on WP_User_Query uses * for wildcard text search, and will search on login, nicename, email and URL, unless specified otherwise. E.g. to match any name containing bob you need: $args = array( ‘search’ => … Read more
You’ve already got the condition you need in your notificationcss() function, so just add the exact same code to track_user_logins(): function track_user_logins( $user_login, $user ){ if ( !current_user_can(‘subscriber’) ) { if( $login_amount = get_user_meta( $user->id, ‘login_amount’, true ) ){ // They’ve Logged In Before, increment existing total by 1 update_user_meta( $user->id, ‘login_amount’, ++$login_amount ); } … Read more
Need help with Task assigning and rewarding as currency which withdrawable
How to hide “Change role to” dropdown on Users admin menu