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

Add a button to users.php

Okay.. you COULD add a button like you mentioned; but I think this is going to require a lot more code. The users.php page is using the WP List Table class.. which means we can hook into the bulk actions and add our custom value there. So, let’s create a function to add a new … Read more

Order by first name

Here is my solution function split_names( $name ) { $names = explode( ” “, trim( join( ” “, $name ) ) ); $first_name = array_shift( $names ); $last_name = array_pop( $names ); $middle_name = join( ” “, $names ); return array( “first_name” => $first_name, “middle_name” => $middle_name, “last_name” => $last_name ); } function sort_by_full_name( $arr1, … 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

Track logged in users’ visits

As it’s a small site, you can do some “real” tracking: // Update the visit time on *every* request function wpse32258_update_usertracking(){ if ( is_user_logged_in() ) { $user_ID = get_current_user_id(); $data = get_user_meta( $user_ID, ‘user_tracking’ ); $data[] = current_time( ‘timestamp’, true ); update_user_meta( $user_ID, ‘user_tracking’, $data ); } } add_action( ‘init’, ‘wpse32258_update_usertracking’ ); // Output the … Read more

Wp_User_Query not sorting by meta key

you can try this code $args = array( ‘meta_query’ => array( array( ‘key’ => ‘score’, ‘value’ => 0, ‘compare’ => ‘>’, ‘type’ => ‘numeric’ ) ), ‘orderby’ => ‘meta_value_num’, ‘number’ => 20 ); $suggested_user_query = new WP_User_Query( $args ); $users = $suggested_user_query->get_results(); echo ‘<div id=”user_suggest”>’; echo ‘<ul>’; foreach ($users as $user) { // get all … Read more

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