get_user_by asking for string while string is given

If your code, you use the first argument passed to wp_authenticate_user filter callback. That is a WP_User object, it not a email address and it is not a string. You may be confusing because of the name of the variable, $username, I suggest to change the name to $user, whcih is more appropiate and it … Read more

How to order users alphabetically by name? in plugin UPME

Diana you must change line of code in this array $args = array( ‘exclude’=> $admin_users_list, ‘number’ => $limit, ‘orderby’ => ‘registered’, ‘order’ => ‘desc’, ‘meta_query’ => array( ‘relation’ => ‘AND’, 0 => array( ‘key’ => ‘upme_user_profile_status’, ‘value’ => ‘ACTIVE’, ‘compare’ => ‘=’ ), 1 => array( ‘key’ => ‘upme_approval_status’, ‘value’ => ‘ACTIVE’, ‘compare’ => ‘=’ … Read more

Loop 1 user randomly

I found a realy great solition here. !! It is a function that kindof ‘adds’ ‘orderby’ => ‘rand’ as a parameter. What it does it that when someone uses that parameter, the function will query the database using regular MySQL, where random is always possible 🙂 The function: // put this in your functions.php add_filter(‘pre_user_query’, … Read more

Get Sticky User in user loop based on user role

If you read the code (in version 4.5.2 on line 164-173) you will see that orderby can be an array of values, coupled with order. So you could modify $args like this: $args = array( ‘orderby’ => array( array (‘sticky’ => ‘DESC’), array (‘registered’ => ‘DESC’)), ‘fields’ => ‘all_with_meta’, ); Note that I know nothing … Read more

How to use a transient inside WP_User_Query

Seeing that the referenced answer stores users_online as an array of timestamps indexed by user ID, you can use the include argument for WP_User_Query: $args = array( ‘include’ => array_keys( $logged_in_users ), // Other arguments );

Add new post only in assigned category

First remove the category metabox from the post edit screen for this particular role, let’s name it onecat-author: if (current_user_can(‘onecat-author’)) { remove_meta_box (‘category’, ‘post’, ‘normal’); } Next, when the post is saved use the available hook to assign the category: if (current_user_can(‘onecat-author’)) { add_action (‘save_post’, ‘wpse_231846_save_cat’, 10, 1 ); } function wpse_231846_save_cat ($post_id) { wp_set_post_categories … Read more

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