Can’t manage to make translate_user_role() work

I think your function nesting is slightly muddled; call ucfirst after translating, like so: esc_html( ucfirst( translate_user_role( $user->roles[0] ) ) ); My bad, completely skipped a beat there. You should instead be using: translate_user_role( $GLOBALS[‘wp_roles’]->role_names[ $user->roles[0] ] ); It’s unreliable to assume that all role display names are simply ucfirst( $role key ). If that … Read more

Removing WordPress Plugin Menu Item for a specific user

Here is the code you need: global $current_user; get_currentuserinfo(); if ( $current_user->user_login === ‘brian’ ) remove_action( ‘admin_menu’, ‘wpcf7_admin_menu’, 9 ); Or if you want to retain your own code, use this: function remove_menus() { global $menu; global $current_user; get_currentuserinfo(); if($current_user->user_login == ‘brian’) { $restricted = array(__(‘Media’), __(‘Links’), __(‘Pages’), __(‘Comments’), __(‘Appearance’), __(‘Plugins’), __(‘Users’), __(‘Tools’), __(‘Settings’), __(‘Contact’) … Read more

get_users() ORDER BY Not Working

Try putting the args into an array. $args = array( ‘role’ => ‘subscriber’, ‘orderby’ => ‘ID’, ‘order’ => ‘DESC’, ‘fields’ => ‘all_with_meta’, ‘meta_query’ => $meta_query ); $my_users = get_users( $args );

Query wp_usermeta alongside wp_users

This is not a simple answer, so first you will need to include one more filter to allow you to grab both the make the meta_query interact with the main query via an OR instead of a AND, check my sample of code: add_filter(‘user_search_columns’, ‘q166419_user_search_columns’ , 10, 3); function q166419_user_search_columns($search_columns, $search, $this){ if(!in_array(‘display_name’, $search_columns)){ $search_columns[] … Read more

Filter user list that meta_value is empty

I think the use of meta_query is in order: $user_query = new WP_User_Query( array( ‘meta_query’=> array( array( ‘key’=> ‘birthday’, ‘compare’ => ‘NOT EXISTS’ ) ) ) ); Basically, this looks for all users where the meta key of birthday doesn’t have a value ie doesn’t exist. More info about meta queries in WP_User_Query can be … Read more

Query All users that has post

add this in your arguments ‘query_id’ => ‘authors_with_posts’, $user_args = array( ‘role’ => ‘frontend_vendor’, ‘orderby’ => ‘display_name’, ‘query_id’ => ‘authors_with_posts’, ‘order’ => ‘ASC’, ‘number’ => $no, ‘offset’ => $offset );

WP_User->add_role producing unexpected results

This would be best as a comment, but no reputation 🙂 In the codex they say “If you are defining a custom role, and adding capabilities to the role using add_role(), be aware that modifying the capabilities array and re-executing add_role() will not necessarily update the role with the new capabilities list. The add_role() function … Read more

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