Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter pzh20

    (@pzh20)

    I believe I fixed this

    Thread Starter pzh20

    (@pzh20)

    I jumped the gun, it is not saving the post. I have made changes to the underlying field group so here is the json file if it helps.

    Many thanks
    Pete

    acfe-export-form-photo-add2-2024-10-23.json

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the feedback!

    In your Form Export, your “Post Action” use the target {form:photo_id}, which means it’s looking for the photo_id argument in your form to know which “post to update”.

    This can be passed either using acfe_form() function:

    acfe_form(array(
    'name' => 'my-form',
    'photo_id' => 45, // pass the 'photo_id' to update the post '45'
    ));

    Or using acfe/load_form filter. See documentation.

    It looks like this is the form you tried to setup in your previous Topic here. Please read this topic and my answers again to make sure evberything is in order.

    In your case, I would recommend to check how the photo_id is passed to the form in your PHP code.

    Hope it helps!

    Have a nice day!

    Regards.

    Thread Starter pzh20

    (@pzh20)

    Hi Again,

    Yes this is the same form as previously, i have not changed the form, b ut the underlying Field Group has changed. I’ve set the source to {form:photo_id}, and I’m querying the same post to add the Featured Image and Post Title befor the form.
    I’ve tried adding a hook to dump the content of the form but it doesn’t seem to be being called.

    add_action('acfe/form/submit_post/form=photo-add2', 'photo2-front_end_after_save_post', 10, 4);

    function photo2_front_end_after_save_post( $form, $post_id ){
    error_log( print_r( $form, true ) );
    error_log( print_r( get_fields($post_id), true ) );
    write_log('Inside PHO - Check data returned (acf extended form)');

    // Get ACF fields

    }

    Not sure what else I can do.

    Regards

    Pete

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    You most likely have an issue at the location where you set the photo_id = '...' in your acfe_form() function or acfe/load_form hook.

    I would recommend to check the PHP code where you set this photo_id, and log the value there to make sure everything is in order.

    If the photo_id doesn’t return a proper Post ID (number), then your “Post Action” will not be executed, as no post can be updated. And thus, the acfe/form/submit_post/form=photo-add2 hook won’t be executed.

    You can check your Form configuration using Global Form hooks (see documentation).

    On form load with acfe/load_form (see documentation):

    // log form on load
    add_filter('acfe/form/load_form/form=photo-add2', 'my_form_load');
    function my_form_load($form){

    // log
    acf_log('load_form', $form);

    // return normally
    return $form;

    }

    On form submission with acfe/form/submit_form (see documentation):

    // log on submit
    add_action('acfe/form/submit_form/form=photo-add2', 'my_form_submit');
    function my_form_submit($form){

    // log
    acf_log('submit_form', $form);

    }

    Both these logs should show you $form['photo_id'] = 45 (any number, is should be a post id). If there is no post id, then check your PHP code where you set it.

    Hope it helps!

    Regards.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.