Trouble with prepare filter
-
I have created two post actions in a form.
First action creates new custom post type and second action updates custom post type.
The idea is that using acfe/form/prepare/post/ filter I want to under certain condition skip first action (create) and trigger second action (update).
<?php function school_form_prepare($prepare, $form, $post_id, $action){ // This a select field, I'm using selected option to get title of the saved/updated CPT $form_school_title = get_field('school_title'); // get_page_by_post_name is my custom function to replace deprecated get_page_by_title() $school_post = get_page_by_post_name($form_school_title, OBJECT, 'school'); $post_school_title = $school_post->post_title; if($form_school_title == $post_school_title){ $prepare = false; } // return return $prepare; } add_filter('acfe/form/prepare/post/form=school-form', 'school_form_prepare', 10, 4);
I can’t get form to update existing post.Form is submitted successfully.
Conditonif($form_school_title == $post_school_title)
is working (I’ve tested it on acfe/form/validation/post hook to display a validition message, if conditon is true).
Any help would be appreciated.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Trouble with prepare filter’ is closed to new replies.