We’re creating a golf tour itinerary system for our purchasers, and we solely need shopper with distinctive reserving reference 221234 to see their tour itinerary, which is on a CPT titled 221234.
Is there a approach that once we create/save a brand new consumer within the backend, on the similar time it ‘robotically’ creates a brand new draft put up in an present customized put up kind and assigns the brand new consumer because the content material writer (proprietor) of that draft put up?
The consumer names are all 6 digit numeric and we would like the title of the draft put up being created to match the consumer identify. We are able to then go in an edit the draft put up, realizing it’s preassigned to the consumer account we created.
So, consumer 221234, has a draft put up titled 221234 within the CPT and is assigned because the Autor of that new draft put up.
We’re designers not coders, and due to this fact we’re creating the system with Toolset and have this conditional assertion overlaying the grasp itinerary content material template, which works very properly for what we’d like.
[wpv-conditional if=" ( ( '[**wpv-current-user info='id'**]' eq '[**wpv-post-author format='meta' meta='ID'** ]' ) ) "]
It does precisely what we would like. Nevertheless we now have to manually assign possession and there are a number of bookings!
So, we have to discover a approach to automate and create the consumer first, then create the draft put up.
We’ve got discovered this code snippet, which seems to be promising, however unsure how we hyperlink this to our CPT
add_action( 'user_register', 'myplugin_registration_save', 10, 1 );
operate myplugin_registration_save( $user_id ) {
$userPostsCategory = 3;
// Create put up object
$my_post = array(
'post_title' => 'Pattern Story' ),
'post_content' => 'You may edit this or create a brand new story',
'post_status' => 'publish',
'post_author' => user_id,
'post_category' => array( $userPostsCategory )
);
// Insert the put up into the database
wp_insert_post( $my_post );
}
The CPT is known as Bookings