Instead of using wp_mail
filter use action user_register
:
function fpw_new_user_post( $user_id ) {
global $wpdb;
update_user_meta( $user_id, $wpdb->base_prefix . 'capabilities', array( 'author' => TRUE ) );
$new_post = array (
'post_title' => 'User ' . get_user_by( 'id', $user_id )->user_login . ' registered @ ' . date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
'post_content' => 'This is my first post.',
'post_status' => 'publish',
'post_author' => $user_id,
'post_category' => array( 0 )
);
$post_id = wp_insert_post( $new_post );
if ( 0 == $post_id ) {
// do some error action
}
}
add_action( 'user_register', 'fpw_new_user_post', 10, 1 );
Based on an assumption that you want this user to publish other posts later, I’ve changed his role to author
. Of course you can set a new post to fit your needs.
Related Posts:
- Why is wp_new_user_notification not working?
- Is it possible to remove username field from the registration page? If so, how?
- users table – user_name vs. nicename
- How can I be certain that a user has verified their email after registration?
- Placeholder text for registration form
- Use the user_activation_key for other purposes
- How to check if the user registration is allowed/active?
- how to disable user confirmation from administration?
- Custom registration form page/template
- Insert “New User” and update/set meta data at once
- Send automatic email to user after wp_create_user
- How to disable or protect against disposable email accounts?
- Registration key
- User defined password at registration – registration email sends auto generated pass
- Advice on setting up a site with front end registration
- How to add a description to the user name input field in the registration form?
- How to add a checkbox to registration and user profile?
- Payment on Registration?
- WordPress members-only page with link visible only to members
- How do I show errors after validation with a custom form frontend?
- How can I find users that didn’t set a password?
- Send custom signup approval email to different Administrators selectively
- Registering without e-mail adress!
- Batch users creation
- After e-junkie payment, send a http post to register user automatically?
- Email confirmation in user registration form without a plugin
- How to add additional information to a user on user creation?
- How to bypass the username as a required field in registration and just use email address instead?
- Invalid key on activation and password reset
- Where are people registering on my website?
- How to disallow user to register with a specific word in the username?
- How can I have user registration verify a whether a new user is listed in a table of pre-approved users?
- Change User Registration
- WordPress Register Form
- Creating custom registration and login link in wordpress
- Adding register & login at top right corner
- Restrict certain character combinations in username during registration
- Register users without confirmation
- Unique registration for new writers to sign up
- Include “registration.php” for custom registration form?
- can registration be enabled programatically?
- register user only with specific Host name
- Generate long hashed user ID
- Disable New User Registration Email sent to WordPress admin email on 4.9.5
- my custom css file downloads then it STOPS!
- Filter for users on custom post type
- Registration area + reserved area
- I want to add a tax-ID field in registration form and upon submission, perform a lookup by tax-ID
- Please suggest me some plugins in WordPress networking
- wordpress – user registration ( signup registration )
- not sending correct link to set the password in registration email [closed]
- Disable password limitations
- How to integrate CAPTCHA on register page? [closed]
- New register email notification sending some fields blank on site admin emai id
- Profile picture in registration form WordPress [closed]
- Controller functionality – User not logged in/ redirect to registration page (not wp_login)
- Register multiple users in one form
- Register through url
- loading custom registration template
- Add ‘first name’, ‘last name’, ‘date of birth’ and ‘terms and conditions’ to register fields?
- How to show password fields on registration form w/o plugins
- Is there any way to not require email address or disable notification upon setting up a member?
- I want to remove the http:// that is added automaticly on the user profile adress
- How to add user registration and signup in WordPress and create members only page?
- Single Sign On or Bridge with in the WordPress WebSites?
- Wikipedia – CMS
- remove (error:) from registration errors woocommerce
- signup_user() throws fatal error
- Action Hook that fires function upon registration at Woocommerce checkout
- Redirection after registration
- My new website registration error
- Updated : how to make email optional while user registration using default wordpress form
- Registration – website crashes, error 403
- Including user data in “new user notification email”
- I want to give every new registering user a unique key apart from password field for external use
- Is it possible to remove the password field in the registration page in woocommerce?
- Custom user registration fields in user_register hook
- Send a password to a user who has just registered for a member area
- The requested URL /wordpress/register/ was not found on this server
- I have restricted the username to numerical format but not able to integrate the same with PeepSo plugin
- Custom Registration with Select and Upload function
- Macros for WordPress, creating subdomains out of registrations for current domain
- How to make user to logged into website & redirect to homepage after successful registration?
- generate an auto incremented id number when a new user is registered
- Remove wp-login link from auto generated wordpress’s email
- Multisite/Network What file to edit to change the “new blog” registration text
- How do spam users register while I’ve only enabled registration by Gmail via Janrain?
- disabling emails received by admins every time a new user signs up (function not working)
- Wrong user registration date in wordpress
- What hooks, actions or filters i can use to customize wordpress registration page and form?
- Can email address be used as user name?
- Website visible only to Registered users (non wp-admin)
- Plugin recommendation for directory site [closed]
- Fields in register page is pre-filled out with name and email
- Login to comment: not just user and email
- Limit username to specific characters (A-Z and 0-9)
- Group users by meta_value
- Change default error message “This email address is already in use” when registering a new user in WordPress using Caldera Forms
- Run custom validation only if all other wordpress registration form validation was successful
- I want to set the shipping_first_name metadata value to match the first_name metadata value for a User on registration using a function