The User and Post forms are two separate form types and cannot be processed on a single form submission.
The best approach is to set up a multi step form where you can create a separate form for the Users and another one for the Post type. Once the user form is submitted it can be redirected to a specific page to which the Post Form is added, ( The redirection can be added from the form settings. )
In order to pass the user information from user form to the post form, Make use of the API <srong>cred_success_redirect and the WordPress Query args
add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data)
{
// Allow to be run on the user form
if ($form_data['id']==86)
$user_data = get_user_by('login', sanitize_text_field($_POST['user_login']));
$arr = array('user_id' => $user_data->ID );
$url = add_query_arg($arr, $url);
return $url;
}
The above code will redirect to the page with the user_id as a url parameter,
To Automatically fetch the url parameter in the post form make the cred_generic fields as below
Could you said me where i have to add this function?
add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data)
{
// Allow to be run on the user form
if ($form_data['id']==86)
$user_data = get_user_by('login', sanitize_text_field($_POST['user_login']));
$arr = array('user_id' => $user_data->ID );
$url = add_query_arg($arr, $url);
return $url;
}