The Post Object field includes new settings allowing users to create and edit post on-the-fly from the post edit screen.
Setting name | Description |
Allow Post Creation | Allow the user to create post in a modal. Allowed post types are based on the “Filter by Post Type” setting. |
Allow Post Edit | Allow the user to edit the post in a modal. |
Setting name | Description |
Allow & save custom value | Allow the user to create post by typing a custom value in the Post Object. The value entered will be used as Post Title |
Post Type | The new Post Type |
Post Status | The new Post Status |
New Post Arguments
/*
* @array $args New Post arguments
* @string $title Post title
* @bool/string $post_id Current Post ID
* @array $field Field array
*/
filter('acfe/fields/post_object/custom_save_args', $args, $title, $post_id, $field);
filter('acfe/fields/post_object/custom_save_args/name=my_post_object', $args, $title, $post_id, $field);
filter('acfe/fields/post_object/custom_save_args/key=field_60131c20e748f', $args, $title, $post_id, $field);
add_filter('acfe/fields/post_object/custom_save_args/name=my_post_object', 'my_acf_post_object_new_post_args', 10, 4);
function my_acf_post_object_new_post_args($args, $title, $post_id, $field){
// Add custom Post Content
// See: https://developer.wordpress.org/reference/functions/wp_insert_post/
$args['post_content'] = 'My post content';
// Stop post creation
// return false;
// Return
return $args;
}
After Post Creation Hook
/* * @bool $new_post_id Newly created Post ID * @string $title Post title * @bool/string $post_id Current Post ID * @array $field Field array */
action('acfe/fields/post_object/custom_save', $new_post_id, $title, $post_id, $field); action('acfe/fields/post_object/custom_save/name=my_post_object', $new_post_id, $title, $post_id, $field); action('acfe/fields/post_object/custom_save/key=field_60131c20e748f', $new_post_id, $title, $post_id, $field);
add_action('acfe/fields/post_object/custom_save/name=my_post_object', 'my_acf_post_object_new_post_action', 10, 4);
function my_acf_post_object_new_post_action($new_post_id, $title, $post_id, $field){
// Do something...
// wp_mail();
}