• Resolved arianagency

    (@arianagency)


    Hello,
    Thanks for creating this plugin

    How to change the Target post_id Update post when updating

    I can dynamically load meta from another post

    but Cannot save it to the post after changes to the form

    example
    post_id 40 Successfully add by filter
    add_filter(‘acfe/form/load/post_id/form=edit_eng’, ‘my_form_post_values_source’, 10, 3);
    function my_form_post_values_source($post_id, $form, $action){
    $post_id = 40;
    }

    but after edit form , the new value not saving to post 40

    i set action update in admin panel

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

    (@hwk-fr)

    Hello,

    Thanks for the feedback. In in order to change the targeted post ID, you should use the following hook:

    add_filter('acfe/form/submit/post_args/form=edit_eng', 'my_form_post_args', 10, 4);

    You will find a code example in the “Advanced tab”, right below the “Change values source” code you’re using ??

    Here is a code example:

    
    add_filter('acfe/form/submit/post_args/form=edit_eng', 'my_form_post_args', 10, 4);
    function my_form_post_args($args, $type, $form, $action){
        
        // Change the ID
        // See 'wp_insert_post' documentation for a list of all arguments
        $args['ID'] = 40;
        
        return $args;
        
    }
    

    Have a nice day!

    PS: It looks like you forgot to return $post_id; in the code example of your post. You should always make sure to return a value when you use add_filter().

    Regards.

Viewing 1 replies (of 1 total)
  • The topic ‘dynamic target on update post’ is closed to new replies.