Support

Account

Home Forums Front-end Issues ACF custom field value from frontend form

Solving

ACF custom field value from frontend form

  • Hey, I have a frontend (woocommerce) modify user details form (myaccount/form-edit-account.php)

    In this form I try to add an ACF custom field to be edited (field ‘birth_date’).

    In the middle of the form, i inserted this code:

    
     <?php acf_form_head(); ?>
    <?php get_header(); ?>
     <?php  the_field('date_of_birth', 'user_1');     ?>
    <?php
        
        $options = array(
                    'post_id' => 'user_'.$user->ID,
                    'fields' => array('date_of_birth'),
                    'form' => false,
                    'instruction_placement' => 'field',
                );
        acf_form($options);
        
        ?>
    

    Now, I think I have to save it using a hook as a user custom field.
    And when I came back to this form to have this field filled with it’s previous info.

    Any idea about the hook and how can I get this field default value when I revisit later this form?

  • I’m not sure what you’re asking. When you create a front end form, there’s a button that says submit and ACF does the rest. Are you not seeing a button?

  • costicanu I’ve got the same problem Have you solved?

    bosoxbill I explain the problem.

    the script show the custom fields. But when you press “Save” the data is not saved.
    But if is an error (like a mandatory field) then it save.

    I think some code have to be not just in form-edit-account.php but somwhaere else.

  • This is the script I use:

    <?php acf_form_head(); ?>
    <?php get_header(); ?>
    <?php  the_field('codfis', 'pec', 'user_'.$user->ID); ?>
    <?php
        $options = array(
                    'post_id' => 'user_'.$user->ID,
                    'fields' => array('codfis', 'pec'),
                    'form' => false,
                    'instruction_placement' => 'field',
                );
        acf_form($options);
    ?>

    codfis and pec are the two custom fields.
    this is how is shown:
    https://www.infomyweb.com/erroracf.jpg

Viewing 4 posts - 1 through 4 (of 4 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.