Update user role for expired membership

If you need to get the value of a field in a custom database table you can try using an SQL query. You’ll have to check the column or table name to construct final version of the query. add_action( ‘profile_update’, ‘my_profile_update’, 10, 2 ); function my_profile_update( $user_id, $old_user_data ) { global $wpdb; $status = $wpdb->get_var( … Read more

user metadata in json format, update the data partly only

You cannot use update_user_meta on its own here. You would need to get_user_meta first, decode your json into an array, update the last_seen element of the array, re-encode it and only then update_user_meta. Unless there is a good reason not to, I would consider just saving these as serialized data (to avoid the json step), … Read more

WP custom posts: filter results to custom taxonomy tag that corresponds to user meta field

You would not do this using SQL, and you don’t need to. Use PHP instead. For example, this code adds a search parameter to the query, but the value changes depending if the user is logged in: add_action( ‘elementor/query/article_video_together’, function( \WP_Query $query ) { $foo = is_user_logged_in(); if ( true === $foo ) { $query->set( … Read more

how to get users with usermeta include array of an array

I solved my problem in another way(WPDB). I wrote a query for this purpose like below: $goal_posts = [31289,31422,77641,41289,21482,17641]; $sql = “SELECT * FROM wp_usermeta WHERE (meta_key = ‘saved_posts’) AND (“; $sql .= implode(” OR “, $goal_posts); $sql .= ‘) GROUP BY user_id’; global $wpdb; $users = $wpdb->get_results($sql);

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