Home Forums Front-end Issues Update field in user registration form


Update field in user registration form

    • udapud

    • January 19, 2021 at 10:29 pm

    I’ve added the field supplier_user_description to ACF in the user roles, and I’m trying to update that info when a user registers with the field key, but it’s not working.
    <?php $user = update_field( 'field_6004677a93a7f', $supplier_description );?>

    This is the field html:

    <label>Supplier Description <span class="error">*</span></label>
    <input type="text" name="supplier-description" class="text" placeholder="Enter Your Supplier Description" required />

    This grabs the field values input by the user:

    <?php global $reg_errors;
        $reg_errors = new WP_Error;

    This is on my custom registration form:

    if ( 1 > count( $reg_errors->get_error_messages() ) )
            // sanitize user form input
            global $username, $useremail;
            $username   =   sanitize_user( $_POST['username'] );
            $useremail  =   sanitize_email( $_POST['useremail'] );
            $password   =   esc_attr( $_POST['password'] );
            $role       =   'Supplier';
            $userdata = array(
                'user_login'    =>   $username,
                'user_email'    =>   $useremail,
                'user_pass'     =>   $password,
                'role'          =>   $role,
            $user = update_field( 'field_6004677a93a7f', $supplier_description );
            $user = wp_insert_user( $userdata );
  • You need to supply the post ID to update_field(). See

    • udapud

    • January 20, 2021 at 1:29 am

    How is there a post ID if I’m registering a new user? Isn’t the ID created when the user is?

    $user = wp_insert_user( $userdata );

    returns the user ID. Update fields after this.

    • udapud

    • January 20, 2021 at 2:21 am

    $user = update_field( 'field_6004677a93a7f', $supplier_description, '$user_{$user_ID}' );

    $user = wp_insert_user( $userdata );

    Seems to break the user registration. Is running the update against the $user variable the best way of updating the ACF field?

    Thanks for your help by the way, this is most excellent of you.

    $user = wp_insert_user( $userdata );
    update_field('field_6004677a93a7f', $supplier_description, 'user_'.$user);
Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.