Save users last visited blogs within whole network

Thank you for your attantion, I made it working with update_user_meta Here is my little function I wrote global $blog_id; $current_blog_details = get_blog_details( array( ‘blog_id’ => $blog_id ) ); if (is_user_logged_in()) { $user = wp_get_current_user(); $last_visited_blogs = get_user_meta($user->ID, ‘last_visited_blogs’,true); if($last_visited_blogs) { if (end($last_visited_blogs) != $current_blog_details->blogname) { if (count($last_visited_blogs) < 5) { array_push($last_visited_blogs, $current_blog_details->blogname); } else … Read more

Exclude Users of a Certain Role in the Users Page

How to use the class methods in the callback The $query object inside pre_user_query is a fully qualified core object, so you can use $query->set( ‘key’, ‘value’ ); as well as $query->get( ‘key’ );. If you got the problem that this might interfere with other callbacks, then simply add remove_filter( current_filter(), __FUNCTION__ ); to your … Read more

Is it necessary to escape LIKE term in WP_User_Query?

like_escape() only escapes % and _ characters. The entire function looks like this: function like_escape($text) { return str_replace(array(“%”, “_”), array(“\\%”, “\\_”), $text); } Quoting from the Codex, esc_attr() Encodes the <, >, &, ” and ‘ (less than, greater than, ampersand, double quote and single quote) characters. Will never double encode entities. Always use when … Read more

Modify user table search results

OK, Here’s how I did it : add_action(‘pre_user_query’, ‘custom_user_list_queries’); function custom_user_list_queries($query){ if(!empty($query->query_vars[‘search’])) { $query->query_from .= ” LEFT OUTER JOIN wp_usermeta AS alias ON (wp_users.ID = alias.user_id)”;//note use of alias $query->query_where .= ” OR “. “(alias.meta_key = ‘billing_postcode’ AND alias.meta_value LIKE ‘%”.$query->query_vars[‘search’].”%’) “. ” OR “. “(alias.meta_key = ‘first_name’ AND alias.meta_value LIKE ‘%”.$query->query_vars[‘search’].”%’) “. ” OR … Read more

Basic Wp_user_query not finding any users

the most basic wordpress user query […] is displaying that it has not found any users You’re passing an empty array of query arguments and there’s an explicit check for that in the WP_User_Query constructor: /** * PHP5 constructor. * * @since 3.1.0 * * @param null|string|array $query Optional. The query variables. */ public function … Read more

Query Users by login, meta & role

It’s not entirely your fault The class responsible for generating the list of users does not honor the pre_user_query filter. This means that any custom column-sorting or filtering that relies on a modified (in pre_user_query) WP_User_Query object will not work. You can see what I mean in the patch below. Admin-user-list-table ignores the filter @@ … Read more

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