How to do a task only once for logged in users

There are various ways to do this, but I’ve recently addressed a similar problem by using cookies. add_action( ‘init’, ‘wpse_93797_cookie’ ); function wpse_93797_cookie() { if ( !isset ( $_COOKIE[‘wpse_93797_cookie_name’] ) ) { // Do your stuff. // Set your cookie so we don’t do stuff the next time around. // Note that 0 makes the … Read more

How do I filter users based on email address?

I wasn’t sure if you meant users or commentators, so I took both. SQL The email is saved in $wpdb->comments in the column comment_author_email for comments. It is saved in $wpdb->users in the column user_email for users. To get the domain part from the email in comments, we can use: SELECT ( SUBSTR( `comment_author_email`, INSTR( … Read more

How to let the users edit their user names?

Is there a way to let the users edit their usernames? no. I think you summarized nicely why this should not be easily possible, since a change of user name will change the URLs of pages in the site something that only an admin should be able to do. Of course you can write a … Read more

Assign random (and unique) user meta upon registration

You can use the hook user_register to modify user data upon registration. You can use the function add_user_meta to add custom data to a user. Example: add_action(‘user_register’, ‘add_pin_number’, 10, 1); function add_pin_number($user_id) { add_user_meta( $user_id, ‘pin_number’, $random_number , true ); } You can look for php function out there to help you creating the random … Read more

Send email to all registered users [closed]

Before you begin, you should know that sending mass emails is a delicate subject matter, and your hosting provider or mail provider has certain guidelines about this. Some hosting providers, such as Dreamhost, provide “Announcement Lists”, which act as a platform for writing newsletters (or essentially emailing a large group of subscribers). Sending unsolicited email … Read more

Users – remove ‘send password’ checkbox

Here are few ideas how to deal with the neutralization of the Send Password part on the /wp-admin/user-new.php page: Idea 1: We can overwrite the wp_new_user_notification() function, because it’s pluggable: Try for example: if ( ! function_exists( ‘wp_new_user_notification’ ) ): function wp_new_user_notification($user_id, $plaintext_pass=””) { $user = get_userdata( $user_id ); // The blogname option is escaped … Read more

Create a “user log”

You can use edit_user_profile_update hook. This action hook is generally used to save custom fields that have been added to the WordPress profile page. add_action( ‘edit_user_profile_update’, ‘update_extra_profile_fields’ ); function update_extra_profile_fields( $user_id ) { if ( current_user_can( ‘edit_user’, $user_id ) ) { update_user_meta( $user_id, ‘my_custom_field’, $_POST[‘your_field’] ); } } With update_user_meta you can check the response … Read more

How to make Users sort in reverse order by default?

You can override the default query arguments using users_list_table_query_args: function wpse_214577_users_list_table_query_args( $args ) { if ( empty( $args[‘orderby’] ) ) $args[‘orderby’] = ‘ID’; if ( empty( $args[‘order’] ) ) $args[‘order’] = ‘ASC’; return $args; } add_filter( ‘users_list_table_query_args’, ‘wpse_214577_users_list_table_query_args’ );

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