Hello,
I'm trying to use cred_save_data to update user meta after submitting a form.
Here is the code I'm using :
add_action('cred_save_data', 'adhesion_membre_modif',10,2);
function adhesion_membre_modif($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==842)
{
$photo_membre = "";
$current_user = wp_get_current_user ();
$user_id = $current_user -> ID;
$nom_membre = $_POST['wpcf-nom'];
$prenom_membre = $_POST['wpcf-prenom'];
$photo_membre = $_POST['wpcf-photo-identite-membre'];
update_user_meta ($user_id, 'wpcf-photo', $photo_membre);
update_user_meta ($user_id, 'first_name', $prenom_membre);
update_user_meta ($user_id, 'last_name', $nom_membre);
}
}
The form (ID 842) has the following content :
[credform]
<div class="row">
<div class="col-sm-6">
[cred_field field='form_messages' class='alert alert-warning']
<div class="form-group">
<label>Civilité</label>
[cred_field field='civilites' force_type='field' class='form-control' output='bootstrap']
</div>
<div class="form-group">
<label>Votre Prénom</label>
(Ne sera jamais visible sur le site)
[cred_field field='prenom' force_type='field' class='form-control' output='bootstrap']
</div>
<div class="form-group">
<label>Votre Nom</label>
(Ne sera jamais visible sur le site)
[cred_field field='nom' force_type='field' class='form-control' output='bootstrap']
</div>
<div class="form-group">
<label>Une photo d'identité de vous</label>
[cred_field field='photo-identite-membre' force_type='field' class='form-control' output='bootstrap']
</div>
<div class="form-group">
<label>Votre date de naissance</label>
(Ne sera jamais visible sur le site. Sert uniquement à définir votre tranche d'âge)
[cred_field field='date-naissance-membre' force_type='field' class='form-control' output='bootstrap']
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label>Présentez-vous en quelques lignes</label>
[cred_field field='description-membre' force_type='field' class='form-control' output='bootstrap']
</div>
<div class="form-group cat-sport">
<label>Vos sports préférés</label>(plusieurs choix possibles)
[cred_field field='category' force_type='taxonomy' output='bootstrap' display='checkbox']
</div>
<div style="display:none;">
[cred_generic_field type='textfield' field='post_title']
{
"required":0,
"default":"[wpv-user [wpv-user field="user_login"]"
}
[/cred_generic_field]
[cred_generic_field type='numeric' field='wpcf-id-utilisateur']
{
"required":0,
"persist":1,
"validate_format":0,
"default":"[wpv-user field="ID"]"
}
[/cred_generic_field]
</div>
<div class="row col-sm-12">
[cred_field field='form_submit' output='bootstrap' value='Envoi' class='et_pb_button']
</div>
</div>
</div>
[/credform]
No errors are reported but no info is stored as user meta.
Any idea of what could be wrong in this code?
Regards
Pat