Support

Account

Home Forums ACF PRO Get the ID of acf-form() submit in ajax call

Helping

Get the ID of acf-form() submit in ajax call

  • Hi,

    I am submitting an acf-form from the front end via an ajax call as follows:-

    var frm = $('#acf-form');
    
        frm.submit(function (e) {
    
            e.preventDefault();
    
            $.ajax({
                type: frm.attr('method'),
                url: frm.attr('action'),
                data: frm.serialize(),
                success: function (data) {		            	
                    console.log('Submission was successful.');
                    console.log(frm.serialize());
                    //console.log(data);
                },
                error: function (data) {
                    console.log('An error occurred.');
                    //console.log(data);
                },
            });
      		
    	});
    
    });

    What I need is the ID of the post when it inserts into the custom post type, is this possible?

  • Is this for a new post? If it is, then there is no post id value. For new posts this value is created by ACF using a built in acf/pre_save_post filter or by a custom filter https://www.advancedcustomfields.com/resources/acf-pre_save_post/.

    The only time that the post ID value will be set is for an existing post and that should be part of the submitted values.

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

The topic ‘Get the ID of acf-form() submit in ajax call’ is closed to new replies.