I have a registration form, Userid input phone number.
I have a custom field is "mobile".
I want to update userid to mobile when user registration form submitted.
Is this code correct to what I want?
//After sending out the application form, let "Process Progress" become "Send In".
add_action('cred_save_data','func_custom_processing_progress',10,2);
function func_custom_processing_progress($post_id,$form_data) {
if ($form_data['id']==214) {
update_post_meta($post_id,'wpcf-processing-progress',1);
update_post_meta($post_id,'wpcf-date-delivery',today());
}
}
Hello. Thank you for contacting the Toolset support.
Well - thank you for creating new ticket. This will help a lot.
As you are dealing with usermeta - you need to use function update usermeta.
add_action('cred_save_data','func_custom_processing_progress',10,2);
function func_custom_processing_progress($post_id,$form_data) {
if ($form_data['id']==214) {
update_post_meta($post_id,'wpcf-mobile',$post_id);
}
}
I have a registration form, The field "Username" let user input phone number.
And I have a custom field is "mobile" in another custom post type "membership mant".
I want to update field "Username" to "mobile" and auto-generate a post of "membership mant" when user registration form submitted.
Can this code achieve my purpose? Thank you.
//After submitted the registration form, auto-generate a member profile, and the username into the mobile field.
add_action('cred_save_data','username_insert_to_mobile',10,2);
function username_insert_to_mobile($post_id,$form_data) {
if ($form_data['id']==83) {
$username = get_user_meta($user_id, 'ms_username', true);
update_post_meta($post_id, 'wpcf-mobile', $username);
}
}
Well - I still do not understand the relationship between post type "membership mant" and user form.
Do you mean that when a new user register with username where you are allowing user to input mobile number as username, so you want to copy the username (mobile number) to the custom field "mobile" of post type "membership mant" and insert one new entry?
Do you mean that when a new user register with username where you are allowing user to input mobile number as username, so you want to copy the username (mobile number) to the custom field "mobile" of post type "membership mant" and insert one new entry?
==> OK
So, when we insert the new entry for post type "membership mant" what title it should have?
Can I have link to your user registration form so that I can look at the fields.
Ok - please check following code - which is using wp_insert_post() function to insert the post and update the mobile number for that post.
//After submitted the registration form, auto-generate a member profile, and the username into the mobile field.
add_action('cred_save_data','username_insert_to_mobile',10,2);
function username_insert_to_mobile($post_id,$form_data) {
if ($form_data['id']==83) {
$username = get_user_meta($user_id, 'ms_username', true);
$my_post = array(
'post_title' => $username,
'post_content' => '',
'post_status' => 'publish',
'post_author' => $post_id,
'post_type' => 'memberhsip_mant'
);
// Insert the post into the database
$insert_id = wp_insert_post( $my_post );
update_post_meta($insert_id, 'wpcf-mobile', $username );
}
}
Could you please share problem URL of registration form and access details.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).
I have set the next reply to private which means only you and I have access to it.