Let's check the logs to see what is happening. Do you know how to activate server logs? If not, I can show you.
Go in your wp-config.php file and look for
define('WP_DEBUG', false);
Change it to:
define('WP_DEBUG', true);
Then add these lines, just before it says 'stop editing here':
ini_set('log_errors',TRUE);
ini_set('error_reporting', E_ALL);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
Then update the wp-config.php file on your server. Next, add error_log statements to your code to see what is happening.
add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
if ($form_data['id']==62)
{
error_log('in form 62');
$userid = $post_id;
$user_info = get_userdata($userid);
error_log('user_info: ' . print_r($user_info, true));
$prenom = $user_info->first_name;
$nom = $user_info->last_name;
$email = $user_info->user_email;
$my_post = array(
'post_title' => $prenom,
'post_status' => 'publish',
'post_author' => $post_id,
'post_type' => 'auteur',
'meta_input' => array(
'wpcf-type' => $_POST['type'],
'wpcf-prenom' => $prenom,
'wpcf-nom' => $nom,
'wpcf-societe' => $_POST['societe'],
'wpcf-telephone' => $_POST['telephone'],
'wpcf-email' => $email,
'wpcf-site-web' => $_POST['site-web']
)
);
$auteur_id = wp_insert_post( $my_post );
error_log('auteur id: ' . $auteur_id);
}
}
Then submit the User Form again. This will create an error_log.txt file in your site's root directory. Please open the file, copy the text, and paste it in your next reply.