get approved users only ( ultimate member plugin )

I assume your WP settings is New User Default Role = contributor If yes, so this block of code shows all the contributor’s with account_status = approved; $args = array( ‘role’ => ‘contributor’, ‘meta_key’ => ‘account_status’, ‘meta_value’ => ‘approved’ ); $users = get_users($args); foreach ($users as $user) { echo ‘<pre>’; print_r( $user ); echo ‘</pre>’; … Read more

Are there individual memory allocations for different user roles in WordPress?

Because of this line in wp-admin/admin.php: if ( current_user_can( ‘manage_options’ ) ) { wp_raise_memory_limit( ‘admin’ ); } In other words, WordPress raises the memory limit to WP_MAX_MEMORY_LIMIT within the admin, but only for users with the manage_options capability i.e. administrators. Your best bet is to raise the default memory limit in your wp-config.php: define( ‘WP_MEMORY_LIMIT’, … Read more

exclude roles from overview

Yes, the get_users_of_blog() function is deprecated, and the reason your code breaks after using get_users() is the ->user_id part, you should use ->ID instead. $blogusers = get_users(); if ($blogusers) { foreach ($blogusers as $bloguser) { $args = array( ‘author’ => $bloguser->ID, ‘showposts’ => 1, ); $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) … Read more

Hide from specific role the top admin bar new button

The item you want to remove is a “node”. When you look at the generated HTML of the WP toolbar, the ID of the list item (<li>) contains the node. So in this case, for the “Add New” toolbar item, you’ll see the following in the HTML: <li id=”wp-admin-bar-new-content” class=”menupop”> Everything after “wp-admin-bar-” in the … Read more

Programmatically allow a non-author to edit a post based custom meta field

Looking at current_user_can()‘s documentation, I see that it uses WP_User::has_cap(). So if your code (or the WP core code) uses something like current_user_can( ‘edit_post’, $post->ID ) to determine if the current user can edit the current post, you can use the user_has_cap filter (called in WP_User::has_cap()): add_filter( ‘user_has_cap’, ‘wpse360937_allow_manager’, 10, 4 ); function wpse360937_allow_manager( $allcaps, … Read more

Remove wordpress author’s capability to moderate comments on their own posts

From quick look at code the likely permissions check for that is edit_comment capability in edit_comment() function. Your options to remove that capability roughly are: customize the role with plugin, for example Members customize role with code, probably using remove cap functionality filter thiungs around map_meta_cap or user_has_cap if you need to achieve more elaborate … Read more

WordPress missing user roles on local dev machine. Live site works fine

I just exported the live database, replaced all occurences of the live siteurl with the local one, and imported on my dev machine. Finding/replacing with a text editor breaks serialized data; you must change values with MySQL queries in phpmyadmin: UPDATE wp_options SET option_value = replace(option_value, ‘http://www.olddomain.com/’, ‘http://www.newdomain.com/’) WHERE option_name=”home” OR option_name=”siteurl”; UPDATE wp_posts SET … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)