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

WP_Query ordered by meta_value_num doesn’t fetch posts without this meta field

The reason you’re only getting those users that have that meta_key is because you’re include ‘meta_key’ => ‘…’ in $args. That limits results to those that have that key, regardless of any clauses you may have in a meta_query. This applies to WP_Query, WP_User_Query and WP_Comment_Query. Starting in WP 4.2, you can “name” the clauses … 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

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