Support

Account

Home Forums Backend Issues (wp-admin) I have successfully added the form but the acf field is not saving

Solving

I have successfully added the form but the acf field is not saving

  • I have upload the image when I try to register a new user but in the user profile there's no image

    Here's my registration form looks

    here’s the code with acf fields functionality, I’ve been doing this for straight 8 hours but I can’t figured it out.

    <div class="row">
    
                            <div class="col-lg-6">
    
                                <div class="form-group">
    
                                    <label>Upload presale permit certificate:<span title="required">*</span></label>
                                    <?php
                                    acf_form_head();
                                    $settings = array(
    
                                	/* (string) Unique identifier for the form. Defaults to 'acf-form' */
                                	'id' => 'acf-form',
                                	
                                	/* (int|string) The post ID to load data from and save data to. Defaults to the current post ID. 
                                	Can also be set to 'new_post' to create a new post on submit */
                                	'post_id' => false,
                                	
                                	/* (array) An array of post data used to create a post. See wp_insert_post for available parameters.
                                	The above 'post_id' setting must contain a value of 'new_post' */
                                	'new_post' => false,
                                	
                                	/* (array) An array of field group IDs/keys to override the fields displayed in this form */
                                	'field_groups' => false,
                                	
                                	/* (array) An array of field IDs/keys to override the fields displayed in this form */
                                	'fields' => false,
                                	
                                	/* (boolean) Whether or not to show the post title text field. Defaults to false */
                                	'post_title' => false,
                                	
                                	/* (boolean) Whether or not to show the post content editor field. Defaults to false */
                                	'post_content' => false,
                                	
                                	/* (boolean) Whether or not to create a form element. Useful when a adding to an existing form. Defaults to true */
                                	'form' => false,
                                	
                                	/* (array) An array or HTML attributes for the form element */
                                	'form_attributes' => array(),
                                	
                                	/* (string) The URL to be redirected to after the form is submit. Defaults to the current URL with a GET parameter '?updated=true'.
                                	A special placeholder '%post_url%' will be converted to post's permalink (handy if creating a new post)
                                	A special placeholder '%post_id%' will be converted to post's ID (handy if creating a new post) */
                                	'return' => '',
                                	
                                	/* (string) Extra HTML to add before the fields */
                                	'html_before_fields' => '',
                                	
                                	/* (string) Extra HTML to add after the fields */
                                	'html_after_fields' => '',
                                	
                                	/* (string) The text displayed on the submit button */
                                	'submit_value' => false,
                                	
                                	/* (string) A message displayed above the form after being redirected. Can also be set to false for no message */
                                	'updated_message' => __("Post updated", 'acf'),
                                	
                                	/* (string) Determines where field labels are places in relation to fields. Defaults to 'top'. 
                                	Choices of 'top' (Above fields) or 'left' (Beside fields) */
                                	'label_placement' => false,
                                	
                                	/* (string) Determines where field instructions are places in relation to fields. Defaults to 'label'. 
                                	Choices of 'label' (Below labels) or 'field' (Below fields) */
                                	'instruction_placement' => false,
                                	
                                	/* (string) Determines element used to wrap a field. Defaults to 'div' 
                                	Choices of 'div', 'tr', 'td', 'ul', 'ol', 'dl' */
                                	'field_el' => 'div',
                                	
                                	/* (string) Whether to use the WP uploader or a basic input for image and file fields. Defaults to 'wp' 
                                	Choices of 'wp' or 'basic'. Added in v5.2.4 */
                                	'uploader' => 'wp',
                                	
                                	/* (boolean) Whether to include a hidden input field to capture non human form submission. Defaults to true. Added in v5.3.4 */
                                	'honeypot' => true,
                                	
                                	/* (string) HTML used to render the updated message. Added in v5.5.10 */
                                	'html_updated_message'	=> '<div id="message" class="updated">%s
    </div>',
                                	
                                	/* (string) HTML used to render the submit button. Added in v5.5.10 */
                                	'html_submit_button'	=> false,
                                	
                                	/* (string) HTML used to render the submit button loading spinner. Added in v5.5.10 */
                                	'html_submit_spinner'	=> '<span class="acf-spinner"></span>',
                                	
                                	/* (boolean) Whether or not to sanitize all $_POST data with the wp_kses_post() function. Defaults to true. Added in v5.6.5 */
                                	'kses'	=> true
                                			
                                );
                                    get_header();
                                    acf_form( $settings );
                                    
                                        defined('ABSPATH') || exit;
                                        // acf_form_head();
                                        
                                        $fields = array(
                                            'presale_certificate', // message
                                        );
                                        
                                        acf_register_form(array(
                                            'id' => 'new-user',
                                            'post_id' => 'new_post',
                                            'new_post' => array(
                                                'post_type' => 'post',
                                                'post_status' => 'publish',
                                                'post_title' => $_POST['acf']['_post_title'],
                                                'presale_certificate' => $_POST['acf']['presale_certificate']
                                            ),
                                            // 'post_title' => true,
                                            'fields' => $fields,
                                            'post_content' => false,
                                            // 'return' => home_url('bibliographie'),
                                            // 'submit_value' => __("Laisser un message", 'jcd'),
                                            // 'updated_message' => __("Message enregistré", 'jcd'),
                                        ));
                                    ?>
                                    <!--<input type="file" class="form-control" name="fileToUpload" id="fileToUpload" required>-->
                                </div>
      
                            </div>
    
                        </div>       
  • Open the image in new tab to view thanks

  • acf_form_head() is in the wrong place.
    The documentation of acf_form_head tels you:” This function must be placed before any HTML has been output, preferably above the get_header() function of your theme file.”

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.