Support

Account

Home Forums General Issues Saving fields to user registration form Reply To: Saving fields to user registration form

  • Thanks Jonathan, but i dont seem to be able to make this work, this it the markup of one of the fields im trying to save:

    <input type="number" id="acf-field-price_from" class="number" min="1" max="10000000000000000" step="1" name="fields[field_55e57136adc2e]" value="" placeholder="">

    and this is the hook im adding to my themes functions file:

    function save_additional_user_meta( $user_id ) {
    
        if ( isset( $_POST['field_55e57136adc2e'] ) )
            update_user_meta($user_id, 'number_of_bedrooms', $_POST['field_55e57136adc2e']);
    }
    add_action( 'user_register', 'save_additional_user_meta', 10, 1 );

    ive tried using the id (acf-field-price_from), name (fields[field_55e57136adc2e]) and field key (field_55e57136adc2e) for the post id, and nothing is getting saved to the db

    i tested the hook by removing the if isset, like this

    function save_additional_user_meta( $user_id ) {
    	update_user_meta($user_id, 'number_of_bedrooms', 'test');
    }
    add_action( 'user_register', 'save_additional_user_meta', 10, 1 );

    and it saves the “number_of_bedrooms” as test, so i know the hook is working, just the syntax might be wrong on the field save function?

    any help is much apreciated