WP_User_Query with combined meta query – not working?

It looks like you’re using wrong parameters, please try this instead (untested): $q = new WP_User_Query( array( ‘role’ => ‘contributor’, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘first_meta’, ‘value’ => ‘2’, ), array( ‘key’ => ‘second_meta’, ‘value’ => ”, ‘compare’ => ‘!=’ ) ) ) ); where we’ve used the key, value and … Read more

order users with drag’n’drop?

Quite a specific feature, never seen any plugin. But it’s a matter of taking a drag’n’drop plugin and adapting it. Here, a stripped and adapted version of My Link Order. Description and to-do: A new submenu is created in Users, My Users Order. In the plugin page, execute the function orderUsers() in your browser console, … Read more

How to Prevent deleting user accounts in WordPress Back-end?

A quick (and dirty) solution would be to prevent the final deletion where it happens (function delete_user). You could implement a little plugin or paste the code into your functions.php: <?php /* Plugin Name: Please don’t delete me! Description: Prevent accidental user deletion of my account */ define(‘PDDM_USER_ID’, 1); // User ID of your Account … Read more

wp_update_user() does not update user_data

The function needs an array with the parameters. See The Codex. Also, you map the parameter with the value: ex. ‘user_email’ => $_POST[‘user_email’]. In your example, the code would look like this: $user_id = (int) $_POST[ ‘ID’ ]; wp_update_user( array( ‘ID’ => $user_id, ‘user_email’ => $_POST[ ‘user_email’ ] ) ); Also, the important hint: you … Read more

Send activation email to user after signup [duplicate]

For activation process you can follow following steps: As you can see user_activation_key column in wp_users table. You can make use of that column for sending user activation link. While signing up users you can insert certain code into that column with custom sql. After the user is signed up with wp_insert_user() and returns an … Read more

How we can get the user id by its display_name

You can use the following function: function get_user_id_by_display_name( $display_name ) { global $wpdb; if ( ! $user = $wpdb->get_row( $wpdb->prepare( “SELECT `ID` FROM $wpdb->users WHERE `display_name` = %s”, $display_name ) ) ) return false; return $user->ID; } This is the same code get_user_by() uses, but since that function only allows ID, slug, email or login … Read more

How to redirect a specific user after log-in?

You need to use the login_redirect filter returning the redirect location: add_filter( ‘login_redirect’, ‘redirect_to_home’, 10, 3 ); function redirect_to_home( $redirect_to, $request, $user ) { if( $user->ID == 6 ) { //If user ID is 6, redirect to home return get_home_url(); } else { //If user ID is not 6, leave WordPress handle the redirection as … Read more

How can I add a user through SQL?

This will create a new admin user called username with password: password in a database called DATABASE with table prefix wp_ Change the two accordingly to your own database name and table prefix. Try this: First create a row in wp_users. Replace DATABASE with your database name, username with your choosen username, password with your … Read more

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