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

Automatically create a default set of posts for each new registered user

A combination of user_register and wp_insert_post should work fine: add_action(‘user_register’, ‘create_postset’); function create_postset($user_id) { // userinfo $user_info = get_userdata($user_id); // Create post objects $post_1 = array( ‘post_title’ => ‘1st post created for ‘ . $user_info->user_login, ‘post_content’ => ‘Lorem Ipsum’, ‘post_status’ => ‘publish’, ‘post_author’ => $user_id ); $post_2 = array( ‘post_title’ => ‘2nd post created for … Read more

How To Disable Add new users On Subsites In Multisite?

To remove the Add Users capability from Administrators (but leave it intact for Super Administrators), you can do this: <?php $role = get_role( ‘administrator’ ); if ( $role->capabilities[‘add_user’] == 1 && ! is_main_site( get_current_blog_id() ) ) { // Because this is saved to the database, we check first // to see if it’s already been … 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