Forum Replies Created
-
AuthorPosts
-
July 18, 2025 at 3:30 AM in reply to: How to Save Vendor First and Last Name to WordPress User Profile #248773
Sathanda SA de CV
ParticipantThank you!
I ended up adding this code snippet, and it worked:
add_action( ‘mvx_after_register_vendor’, ‘shshapp_save_vendor_names’, 10, 1 );
function shshapp_save_vendor_names( $user_id ) {
if ( ! $user_id ) {
return;
}// Verifica que existan los campos personalizados enviados
if ( ! isset( $_POST[‘mvx_vendor_fields’] ) || ! is_array( $_POST[‘mvx_vendor_fields’] ) ) {
return;
}$fields = $_POST[‘mvx_vendor_fields’];
$first_name = ”;
$last_name = ”;// Itera los campos para encontrar “Nombre (s)” y “Apellidos”
foreach ( $fields as $field ) {
if ( isset( $field[‘label’] ) && isset( $field[‘value’] ) ) {
if ( $field[‘label’] === ‘Nombre (s)’ ) {
$first_name = sanitize_text_field( $field[‘value’] );
}
if ( $field[‘label’] === ‘Apellidos’ ) {
$last_name = sanitize_text_field( $field[‘value’] );
}
}
}if ( $first_name ) {
update_user_meta( $user_id, ‘first_name’, $first_name );
}if ( $last_name ) {
update_user_meta( $user_id, ‘last_name’, $last_name );
}
} -
AuthorPosts
