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.
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.