Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
But why you added the form to this page:
- hidden link
and
- hidden link
The workflow we discuss is the form you will create that will create child entry in one-to-many post relationship should be added to the single post of your parent - right? so that we can grab the parent post ID from your parent post and then based on that parent post ID we will get the parent post author.
Okay, now it gets a bit more complicated. 🙂
I added an extra field (school name).
This could be a hidden field in which the USERNAME is automatically filled in.
So that the site visitor can search by USERNAME
Can the forms not be placed on these pages?
FYI, it's 2 forms for posting 2 types of posts.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
I've added the following code to "Custom Code" section offered by Toolset:
- hidden link
add_action('cred_save_data','func_save_user_name_to_schoolnaam', 10, 2);
function func_save_user_name_to_schoolnaam($post_id, $form_data){
// if a specific form
global $current_user;
$forn_ids = array(1095,1033);
if (in_array($form_data['id'],$forn_ids)){
update_post_meta($post_id,'wpcf-schoolnaam',$current_user->user_login);
}
}
As you can see we are updating the "schoolnaam" custom field value with the current user login.
Now, when you submit the form the "schoolnaam" custom field value will be automatically filled.
Note: I've removed the custom field "schoolnaam" you added to your form as its not required and the "schoolnaam" custom field value will be automatically filled using "cred_save_data" hook.
Very happy with your help!!!
Have a nice day!