Hi @rpiket and thanks for reaching out!
There is no built-in function to do that, but you could easily use the save_post_{$post->post_type} hook of WordPress.
Link: https://developer.ww.wp.xz.cn/reference/hooks/save_post_post-post_type/
Something like:
add_action( 'save_post_gigpress_show', 'create_post_with_show', 20, 3 );
function create_post_with_show( $show_id, $show, $update ) {
// Bail on autosaves, revisions, and trash transitions.
if ( wp_is_post_autosave( $show_id ) || wp_is_post_revision( $show_id ) ) {
return;
}
if ( in_array( $show->post_status, [ 'auto-draft', 'trash', 'inherit' ], true ) ) {
return;
}
// Avoid recursion when wp_insert_post / wp_update_post fires save_post.
remove_action( 'save_post_gigpress_show', 'gpr_companion_post_sync', 20 );
// DO YOUR STUFF HERE
add_action( 'save_post_gigpress_show', 'gpr_companion_post_sync', 20, 3 );
}
I hope this helps. Let me know if you have any further questions, or if we can close this as resolved.
Cheers,
Andras
Thread Starter
rpiket
(@rpiket)
Thanks for your response. With the help of AI I was able to generate a plugiin to create a standard WP post whenever an event is created. It’s working great. I’d be glad to share it with you if you think it would be useful.
Great job @rpiket!
Unfortunately, I have to close this plugin. Thank you for your support.
Thread Starter
rpiket
(@rpiket)
That is very disappointing. I spent a lot of time getting this to work. Now I’m back in the same boat with a plug-in that will eventually not be compatible with later versions of WP and PHP.
Why did you even bother to create it if you were going to shut it down after a month??
Hi @rpiket
Yes, I know. I’m currently evaluating my options for the future.
A.