Hi,
Please check this hooks for the attach Success message when post is published
add_action( 'draft_to_publish', 'your_functions_name', 10, 1 );
add_action( 'publish_post', 'your_functions_name', 10, 2 );
Other hook for the attach Success message when post is saved.
add_action( 'save_post', 'your_functions_name' );
what to wirte in function, i just want alert success! message
function on_post_publish( $strOldStatus, $strNewStatus, $post) {
// A function to perform actions when a post is published.
if( ( $strOldStatus === ‘draft’ || $strOldStatus === ‘auto-draft’ ) && $strNewStatus === ‘publish’ ) {
echo ‘<script type=”text/javascript”>alert(“Success!!”);</script>’;
}
}
i tried this but no use, please let me know wrong in this code
Hi, you can try with the POST data when you publish or update the post.
For example:
In functions.php, please do type below code and do action on posts like update or create a new post.
print_r($_POST);
In this POST data, you will find the condition that will match your criteria like current action, post_publish_type or any other unique action you can use to put the conditional logic.