1

I created a field to enter whatsapp number in the front of a site in wordpress, since the back is simple, but I need to change it from the front section for the users enter image description here

I have already placed an input where I show the user's information, the other fields already come by default in the subject.

<div class="form-group">
  <div class="stm-label h4"><?php esc_html_e('Whatsapp', 'motors'); ?></div>
   <?php $author_id = get_the_author_meta('ID');
                       $author_badge = get_field('n_whatsapp', 'user_'. $author_id );
                      ?>
        <input class="form-control" type="text" name="stm_phone"
                               value="<?php echo esc_attr($author_badge); ?>"
                               placeholder="<?php esc_html_e('Incluir whatsapp', 'motors'); ?>"/>
                </div>
                <input type="text" id="id_whatsapp" name="acf[n_whatsapp]" value="acf[n_whatsapp]">
                <?php acf_form(); ?>
              </div>
            </div>

2 Answers 2

0

If you want to include your own inputs on the acf_form() you should use some of its parameters to allow the form submit them. Otherwise your inputs will be out of the form. As an example you could use this code:

<?php
acf_form(
       array(
                'html_after_fields' => '<input type="text" id="id_whatsapp" name="acf[n_whatsapp]" value="acf[n_whatsapp]">',
            )
        );
?>

You can check all the parameters acf_form() accepts here: https://www.advancedcustomfields.com/resources/acf_form/

Hope this helps.

0

You are missing the arguments array from ac_form function. You can show the acf fields by using fields attribute. You can pass one or more keys of the acf fields to show in the form.

You can also use field_groups attribute if you want to show whole fields of the group in the form. Acf save function will automatically saved the value after submission of the form.

For arguments of the array passed into the acf_form please see the documentation => https://www.advancedcustomfields.com/resources/acf_form/

2
  • Can you help me with an example? I've read the truth but I do not understand many things, I'm started with this and it has flown somewhat complicated,
    – develop12
    Jan 17, 2019 at 20:54
  • yeah sure, Here is the sample code => $settings = array( 'form' => false, 'fields' => array( 'field_name' ), ); acf_form( $settings ); You can use above code to show your custom field in the form. I am using form false because I dont want acf form. I want just acf field in my own form. But if you want acf form then set form => true and please also change the name of the field_name with the field name you want. Jan 18, 2019 at 4:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.