Hello,
Thanks for the feedback. The Generated ID is simply the actual Post ID.
1/ In order to retrieve the Post ID of the created post, you have to set a custom action name in your “Post Action”. Once you’ve set a custom name, you have to enable the “Query Var” switch.
This will create a new template tags {query_var:my-action-name:ID}
, {query_var:my-action-name:post_title}
etc… You’ll find a list of all available template tags for the post creation in the “Cheatsheet” tab. In your case, you have to use {query_var:my-action-name:ID}
in the success message.
Note: You have to leave the “Redirection” field blank, because query var cannot be used in conjonction with redirection.
Here is a screenshot example: https://i.imgur.com/vn3kALc.png
2/ As the generated ID is simply the Post ID, you can use update_field()
on Post Save, using the following hook:
/**
* @int $post_id The targeted post ID
* @string $type Action type: 'insert_post' or 'update_post'
* @array $args The generated post arguments
* @array $form The form settings
* @string $action The action alias name
*
* Note: At this point the post & meta fields are already saved in the database
*/
add_action('acfe/form/submit/post/action=my-action', 'my_form_post_save', 10, 5);
function my_form_post_save($post_id, $type, $args, $form, $action){
/*
* Add the Post ID in a custom field
*/
update_field('my_field', $post_id, $post_id);
}
See the “Advanced” tab in Post Action for more hook examples.
Hope it helps!
Have a nice day.
Regards.