alphabetically order role drop-down selection in dashboard

Almost the same approach One Trick Pony has chosen, but I am using translated names and uasort() (to preserve the keys): add_filter( ‘editable_roles’, ‘t5_sort_editable_roles’ ); /** * Array of roles. * * @wp-hook editable_roles * @param array $roles * @return array */ function t5_sort_editable_roles( $roles ) { uasort( $roles, ‘t5_uasort_editable_roles’ ); return $roles; } /** … Read more

How can 2 blogs share the same users

I think you want to install your second site on the same database but with a different table prefix, e.g. $table_prefix = “qa_”; in wp-config.php You are then able to define a custom user and/or user_meta table by adding the following lines to wp-config.php define(‘CUSTOM_USER_TABLE’, [orig_table_prefix].’my_users’); define(‘CUSTOM_USER_META_TABLE’, [orig_table_prefix].’my_usermeta’); Source: http://codex.wordpress.org/Editing_wp-config.php#Custom_User_and_Usermeta_Tables I have read somewhere before … Read more

Ban a user and end their session

Use wp_logout(). It calls wp_clear_auth_cookie() and invalidates the current log-in information immediately. Sample code, not tested: add_action( ‘init’, ‘log_out_banned_user’ ); function log_out_banned_user() { if ( ! is_user_logged_in() ) return; $user = wp_get_current_user(); if ( ! get_user_option( ‘rc_banned’, $user->ID, false ) ) return; wp_logout(); wp_redirect( home_url( “https://wordpress.stackexchange.com/” ) ); exit; }

Email user when password is reset by admin

Here’s one way to add this feature using the following flowline : The admin updates the user option page: -> edit_user_profile_update or personal_options_update hooks activated -> edit_user() function is called -> wp_update_user() function is called within edit_user() -> wp_insert_user() function is called within wp_update_user() -> profile_update hook activated within wp_insert_user() for user updates, not user … Read more

How to change user_login with wp-cli?

Not allowed by design: If we try to change the user login by the email: wp user update [email protected] –user_login=mary_new or by the user id: wp user update 123 –user_login=mary_new we get the following warning: User logins can’t be changed. This is the reason: if ( isset( $assoc_args[‘user_login’] ) ) { WP_CLI::warning( “User logins can’t … Read more

Automatically delete inactive users after 2 months

Your query is wrong because your third argument to TIMESTAMPDIFF is incorrect. You should be using meta_value instead of SELECT meta_value. SELECT user_id FROM wp_usermeta WHERE meta_key = ‘wp_wp_kc_last_active_time’ AND TIMESTAMPDIFF( second, now(), TIMESTAMP(meta_value) ) > 5184000; Try that and see if the results start looking correct. I just checked over the mySQL Date Function … Read more

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