Forum Replies Created

  • Thanks for taking the time to respond! Seems pretty obvious now. Appreciate your help.

  • I have almost this exact same scenario. Were you ever able to get this working?

  • This is what I needed. Thanks for taking the time to respond!

  • 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?

  • Thanks so much for taking the time to help me out! The above solution worked perfectly.

    My only question now is, could I show a different “Submit” button conditional on whether or not a date was selected. For example if a date is selected show “Schedule” button, if not show “Create Post” button?

    I’ll see if I can figure this out.

    Thanks so much again for the great support.

  • Hi,

    Thanks so much for the response. I apologize I am not very advanced with using php.

    This is what my current form looks like:

    <?php acf_form_head(); ?>
    <?php /* The loop */ ?>
    			<?php while ( have_posts() ) : the_post(); ?>
    					'post_id'		=> 'new_post',
    					'post_title' => true,
    					'new_post'		=> array(
    						'post_type'		=> 'shareable',
    						'post_status'  => 'future' ,
    					'submit_value'		=> 'Create post'
    				)); ?>
    			<?php endwhile; ?>

    I am unclear on how to use the function acf-pre_save_post to set the post date variable.

    I have a datepicker field added formatted like Y-m-d. Would the below code work with my form added above <?php acf_form_head(); ?> at the top of my template?

    function my_pre_save_post( $post_id ) {
        // check if this is to be a new post
        if( $post_id != 'new' ) {
            return $post_id
    // The date picker field
    $postdate = get_field('schedule_post');
        // Create a new post
        $post = array(
            'post_status'  => 'future' ,
            'post_date'  => '$postdate' ,
            'edit_date' => 'true'
        // insert the post
        $post_id = wp_insert_post( $post ); 
        // return the new ID
        return $post_id;
    add_filter('acf/pre_save_post' , 'my_pre_save_post', 10, 1 );
  • I would love to have this functionality as well. Please post here if you are able to get this working. I’ll be working on a solution for this as well and will let you know if I come up with anything.

  • Thanks for posting this. This is exactly what I’m looking for. Would you mind posting your entire form code? I’m having trouble following exactly what you did.


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