How to make WordPress ‘editor’ role to list/view/add/edit users only with the role ‘author’?

In addition to the code piece in the question, 1. To display only the author roles in the user list page of editor: add_action(‘pre_user_query’,’editors_edit_author_list’); function editors_edit_author_list($user_search) { $user = wp_get_current_user(); if($user->ID != 1) { $user_meta=get_userdata($user->ID); //$user_roles= $user_meta->roles; global $wpdb; if(in_array(‘editor’, $user_meta->roles)) { $user_search->query_where = str_replace( ‘WHERE 1=1’, “WHERE 1=1 AND {$wpdb->users}.ID IN ( SELECT {$wpdb->usermeta}.user_id … Read more

SQL to set Display Name to First Name + Last Name

Figured out the SQL query that can be used to reset the display_name to first_name + last_name. And it’s simpler than the JOINs that I was trying when I posted the question. UPDATE wp_users SET display_name = Concat( (SELECT meta_value FROM wp_usermeta WHERE meta_key = ‘first_name’ AND user_id = id ), ‘ ‘, (SELECT meta_value … Read more

Display custom user profile fields in wordpress

i’m using this answer as a playground for helping you out here. better, than in the comment section. for anybody else stumbling about the same question: i recommended ACF as a plugin for custom fields, as it is well maintained and can add custom fields to anything inside wordpress (posts, pages, attachments, taxonomies…) to get … Read more

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