Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Sathanda SA de CV
    Participant

    Thank 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 );
    }
    }

Viewing 1 post (of 1 total)
Shopping Cart
Scroll to Top