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

Check if user is admin by user ID

You worded it as you want to check if user has administrator role. It is considered more proper to check for capability, relevant to specific action. In practice this is usually expressed as current_user_can( ‘manage_options’ ) for current user. For arbitrary user it would be user_can( $user_id, ‘manage_options’ ). Of course this is capability that … 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

WP_User_Query and non-unique usermeta data

The solution that we have gone with in the end uses a single call to get_user_meta passing just the $user_id – this way all user data is returned in a single query, reducing a heavy load on the DB during large user data exports. We then run a series of checks against the returned data … Read more

What’s the difference between the capability remove_users and delete_users?

The difference is really no difference in regular (single install) WordPress. It’s in a multisite install (network) where there is a difference. In multisite, only a Super Admin (who can manage everything on the network) has delete_users capability, while an “admin” (who would own/manage a single site) can remove_users from their site, but cannot delete … Read more

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