i'm having a trouble with Wordpress, with the function update_user_meta()
I'm trying to update or add a new custom meta value for the user, who already have the custom meta working on the edit profile.
But when i do the function update_user_meta()
outside the edit-profile.php
, just didn't work for me.
I have a page like a page of contact where the form will edit the custom metadata of the profile, in the front side of the wordpress like a normal page of wordpress, but when he submit the form, he just don't update, here is my code:
when the user submit:
function update_termini() {
$user = wp_get_current_user();
$userData = array();
$userData['checkbox'] = intval( $_POST['custom_user_fields_checkbox'] );
update_user_meta( $user, 'custom_user_fields', $userData );
}
add_action('edit_user_profile', 'update_termini');