Support

Account

Home Forums Front-end Issues Front-end form is creating 2 posts

Solved

Front-end form is creating 2 posts

  • Hi,

    I have a front end form creating a custom post type. Everything was working perfectly until recently it started creating 2 posts every time the form is submitted. Does anyone have any ideas what could cause this? Could it be a javascript conflict? Or, should I look somewhere else?

    Below is the code for my form. Any help would be appreciated.

    <?php /* The loop */ ?>
    			<?php while ( have_posts() ) : the_post(); ?>
    
    				<?php acf_form(array(
    					'post_id'		=> 'new_post',
    					'post_title' => true,
    					'new_post'		=> array(
    						'post_type'		=> 'shareable',
    						'post_status'		=> 'publish'
    					),
    					'submit_value'		=> 'Create post'
    				
    
    				)); ?>
    
    			<?php endwhile; ?>
  • UPDATE: I was able to determine it is a plugin I am using to defer the loading of all JavaScripts added by the way of wp_enqueue_script().

    WP Deferred JavaScripts

    The plugin does provide a way to exclude a script from being deferred but I am not sure where to look for the script ACF is using.

    Here is the filter the plugin provides:

    // Don't defer this script.
    add_filter( 'do_not_defer', 'exclude_canvas_script' );
    function exclude_canvas_script( $do_not_defer ) {
        $do_not_defer[] = 'my-canvas-script';
        return $do_not_defer;
    }

    Anyone know if there is a way to use this with ACF?

  • Like I said in the other topic, the only reason I can think of is that the plugin used to defer script is not handling the localization properly. The information I’ve read in that plugin suggest that it’s supposed to as long as scripts are registered, localized and enqueued correctly. I’ve looked through all the code where this is done in ACF and it all looks like it’s being done correctly to me.

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

You must be logged in to reply to this topic.