Dear Sir/Madam,
I know how to use the WP user_register hook and also the Toolset my_save_data_action(). I will have two user forms for new user to register.
1. Register only
2. Register and then apply the application.
As user_register hook is automatically be triggered and a new user be created, here is the change to my user_register hook
function auto_application($user_id){
if (!$user_id>0)
return;
$new_post = array(
'ID' => '',
'post_author' => $user_id,
'post_status' => 'publish',
'post_type' => 'application',
'meta_input' => array(
'wpcf-competition-id' => $_POST['application-type'],
)
);
$post_id = wp_insert_post($new_post, 1);
wp_update_post( array(
'ID' => $post_id,
'post_name' => $post_id,
));
}
add_action( 'user_register', 'auto_apply_competition', 10, 1 );
As there are two forms will do the registration, how can I check which user form I called from and I can do different action?
Best regards,
Kelvin
Hello Kelvin and thank you for contacting the Toolset support.
What if you used the "cred_save_data" hook from Toolset, instead of "". Read more about it here https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
The hook is used for both, post forms and user forms, and the $post_id is either the created/edited post_id or user_id.
Let me know if you must use "user_register" and I'll find a way to help.