I might not be thinking this right but here is my situation:
events
.wp_insert_post()
(in a plugin), some are added manually in the admin edit screen.post_meta
but only if the post is added manually (through the admin edit screen).So I am hooking into save_post_events
and performing some security checks but I have no idea how to check if the request is only coming from the admin edit page because right now the save_post
action triggers also if the post is added with the wp_insert_post
function.
Any ideas?
Thanks
I might not be thinking this right but here is my situation:
events
.wp_insert_post()
(in a plugin), some are added manually in the admin edit screen.post_meta
but only if the post is added manually (through the admin edit screen).So I am hooking into save_post_events
and performing some security checks but I have no idea how to check if the request is only coming from the admin edit page because right now the save_post
action triggers also if the post is added with the wp_insert_post
function.
Any ideas?
Thanks
I have found a solution without adding any other metaboxes. I haven't thought about it but the import function in my plugin uses a nonce
so I just check if my nonce is set or not.
Here is my save_post_events
function:
add_action( 'save_post_events', 'wse_327066_example', 10, 3);
function wse_327066_example( $post_id, $post, $update ) {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE || $post->post_status == 'trash' || !current_user_can( 'edit_posts' ) || isset( $_POST['_import_nonce'] ) )
return;
# Now I can do whatever I want with posts saved from the admin edit screen...
}