I want to get the last inserted id from the database I have tried many code am not able to get last insert id. I have given below the following my code. Please any one help and save me.
$users_table = $wpdb->prefix."users";
$saveFieldArray=array('user_login'=>'$utilisateurCand',
'user_pass'=>'$passeCand',
'user_email'=>'$emailCand',
user_registered=>CURRENT_TIMESTAMP());
$wpdb->insert( $users_table, $saveFieldArray);
echo $wpdb->last_query;
echo $lastInsertId = $wpdb->insert_id;
Basically - if you use WPs own function, then you get the ID on success
Like this.