Modified your code above to post to the custom post type “Bookings,” set to draft, and use the user ID number as the post title. I also added a return value for the new post id so redirecting to that id or linking to it is much easier.
add_action( 'user_register', 'myplugin_registration_save', 10, 1 );
function myplugin_registration_save( $user_id ) {
$userPostsCategory = 3;
// Create post object
$my_post = array(
'post_title' => $user_id,
'post_content' => 'You can edit this or create a new story',
'post_type' => 'Bookings',
'post_status' => 'draft',
'post_author' => $user_id
);
// Insert the post into the database and return new post id
$itinerary_id = wp_insert_post( $my_post );
return $itinerary_id;
}
Related Posts:
- Creating a custom post type upon registration
- Get current user id
- Creating a custom post type upon registration for a specific user role
- UPDATED: Save a custom_field value when automatically creating a post using wp_insert_post
- Updating User Meta from Custom Post Field Upon Publish Not Working
- Can I list a custom post type within another custom post type in the admin area?
- Change custom post type slug from plugin options
- Can’t edit custom post type
- Set URL link to featured image of custom post type
- Change CPT archive title
- AJAX load more for different custom post type loops
- PHP variable not regenerating when publishing multiple posts at the same time
- Team club with CPTs and user registration + user dashboard
- On update or create post redirect to current post position in list
- I need to add endpoint for wordpress categories
- Only view/edit/delete CPT made by users with the same role
- Cluster CPT posts to users based on ACF value from their profile on dashboard
- Restrict Access to Posts based on Custom User and Post Meta Data
- How to target a specific custom post type post and its all children and grandchildren?
- Featured image overlay when changing post status
- get_post_meta not working on publishing
- Redirect 404 page with ID in slug to associated page with same ID in slug
- WordPress wrapped added a span tag to every single p tag
- ACF field key/value to show on taxonomy list
- Re-registering a custom post type not working (not showing up)
- Display featured image from one CPT within another CPT query
- Query taxonomy of taxonomy of custom post type
- Best way to style first post differently?
- How to make custom posts types display when published for the future
- How to rewrite url for any specific taxonomy?
- create a new page from a custom post type similar to an authors page
- CPT archive admin menu label
- Anon function and add_meta_box
- Users create/join groups
- Hide a widget inside a div on specific type of post
- Shortcode not working with post counter
- Changing default ‘posts’ parameters with register_post_type_args
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Query posts based on the meta key values of logged-in users?
- Cannot save CPT meta box
- Allow users to create posts without logging in?
- How to change permalink to include custom post type
- Creating a Custom Post Type and Joining with Users
- Configuring a meta query with multiple post types that have the same relationship on a single page
- re-register custom post type with custom capabilities
- Add term to custom post type on draft
- How to assign classes to all elements?
- next_/previous_post_link() `in_same_category` appears to fail when true
- Want to be able to sign up subscribers as authors
- Load scripts based on post type
- Different Category system needed for the Custom Post Type
- Global custom meta box
- Template not working for the custom Post type
- Warning: Invalid argument supplied for foreach() [closed]
- Custom post type isn’t working
- Meta-Boxes for CustomPostType cause PHP Errors and Notices in “Add New” view
- categories should be available across all custom post types
- Warning: Invalid argument supplied for foreach() in post.php [closed]
- Featured Image field not appearing in Custom post type
- Post-thumbnail only for specific post-types?
- custom post type metaboxes not saving
- Custom Post Type & Custom Menu Walker to append custom class for active post types
- Enable taxonomies by post type in an array of CPTs
- PHP question: how to combine syntax?
- Loop increase number
- custom post for slider
- ACF in wordpress
- Change Slug of a Custom Post Type
- Excerpt function for any content
- Assign category a default post type
- Navigate posts with different post type that are in the same categories
- List of all entries of custom-post-type: Add year-parameter?
- Add an Outside Wrapper to my Header and Make it Full Width
- Page Template Dropdown For Custom Post Types
- Showing custom post type categories in the menu
- How to use a variable as a function name?
- Show Custom Message in WordPress Admin
- How to inherit field value from parent post into in child / sub post
- How exclude or skip post type with get_next_post_link
- Prevent A Specific Custom Post Type Showing In WP Search Results Page
- Create short URL with auto 301 redirect
- Custom post type’s posts are not showing anywere but in xml sitemap
- providing access to post_id or post inside functions.php
- How do I create a new post upon registration with the users first and last name as title
- Removing full title and breadcrumb header container for a specific post type
- Is it possible to use array_walk() to append terms to an array of posts?
- WordPress notification if new post published
- Run shortcode in custom script in wp_head if post type is CPT ‘Jobs’
- Show current user posts in custom post type query
- Custom Ratings for Theme, Proper way to Refactor Code and Clean up Template File
- Rewrite permalink for multiple post types (CPT) with taxonomy term
- Get post format
- posts within custom post type all share the same content in the front-end
- post_content is stripping HTML when adding a new post? [closed]
- Shortcode to return single custom post based on post taxonomy
- Custom post type in Custom widget – $listItem
- Using Wp_Query, Json to add Highcharts series data
- Template code to split a post and print a custom field?
- Send post changes to set email addresses (not users or subscribers)
- Custom posts – tag pagination