• Resolved theblueli

    (@theblueli)


    Hello.

    I have a question see if it is possible to get a workaround.

    I tested 2 plugin popular filter plugin on the market, WP Grid Builder and Facet WP

    Their facet indexer will be trigger whenever a post is created or updated.

    However it does not work when ACFE form updated a post or created a post. Any possible idea to make it works?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the feedback!

    I’m not a FacetWP/WP Grid user so I don’t really know how they work. What I can tell you is that ACFE Form use the native WP function wp_update_post() (see documentation) to update the post behind the scene.

    Small note: If you’re displaying the posts grid on the same page as the ACFE Form, you can try to refresh the page with F5 once the form is submitted. If that fixes the issue, it means the “Post Update” comes too late during the page render, and you need to redirect the form on submission using a Redirect Action (see documentation).

    Other than that, I don’t know if these plugins automatically check the usage of wp_update_post() to re-check their index, or if they require a manual intervention with some custom code/function to do it. I would recommend to contact their support, or check their documentation about this.

    You can add some third party function in your “Post Action” submission using the acfe/form/submit_post hook (see documentation). Usage example:

    add_action('acfe/form/submit_post/form=my-form', 'my_post_submit', 10, 4);
    function my_post_submit($post_id, $args, $form, $action){

    // call third party function on post update
    my_check_index();

    }

    If these plugins require you to set some custom argument passed to the wp_update_post(), then you can alter the arguments using the acfe/form/submit_post_args filter (see documentation). Usage example:

    add_filter('acfe/form/submit_post_args/form=my-form', 'my_post_submit_args', 10, 3);
    function my_post_submit_args($args, $form, $action){

    // add third party argument
    // passed to wp_update_post()
    $args['my_check_index'] = true;

    // return
    return $args;

    }

    Note my_check_index and my_check_index() are just examples and won’t do anything. You need to contact the third party plugin support to know what method to use to trigger their “refresh” logic.

    Hope it helps!

    Have a nice day!

    Regards.

    Thread Starter theblueli

    (@theblueli)

    Hi

    I managed to resolve it by your example code my_post_submit() with WP grid builder

    For anyone who wonder how.

    add_action('acfe/form/submit_post/form=shop-edit', 'my_post_submit', 10, 4);
    function my_post_submit($post_id, $args, $form, $action){
    // Call WP Grid Builder function to refresh the index
    if ( method_exists( '\WP_Grid_Builder\Includes\Indexer', 'index_facets' ) ) {
    ( new \WP_Grid_Builder\Includes\Indexer() )->index_facets( -1 );
    }
    }

    Thank you for the help!

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello!

    Awesome, good job!

    Have a nice day!

    Regards.

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