I am developing a WordPress plugin.
Everything works properly, but I don’t know how to display a message to the admin:
function example_send_notifications( $post_id ) {
// do something (it works)
// then I need to display a success or failure message to the admin in the editor
// e.g. show_admin_message( ‘Notifications sent!’ );
}
add_action( ‘publish_post’, ‘example_send_notifications’, 10, 1 );
How can I achieve that (**display a message to the admin in the Gutenberg editor**)?
I would like the message to have a style similar to the “Post published” toast message that is displayed by WP in the bottom left corner.
[ad_2]
I found the problem:
[https://developer.wordpress.org/block-editor/how-to-guides/notices/])
It seems that I need to use Javascript for Gutenberg.
I still don’t understand how to use that JavaScript code from the `publish_post` callback..