Creating a custom post type upon registration for a specific user role
Try below code: add_action( ‘user_register’, ‘create_new_post_onuser_registration’, 10, 1 ); function create_new_post_onuser_registration( $user_id ){ // Get user info $user_meta = get_userdata( $user_id ); $user_roles = $user_meta->roles; // Update the role here if ( in_array( ‘subscriber’, $user_roles ) ) { // Do something. // Create a new post $subscriber_post = array( ‘post_title’ => $user_meta->nickname; ‘post_content’ => $user_meta->description, … Read more