Advertisement
Abubakar1309

publish post hook

Jul 26th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. function post_published_notification( $ID, $post ) {
  2. $author = $post->post_author; /* Post author ID. */
  3. $name = get_the_author_meta( 'display_name', $author );
  4. $email = get_the_author_meta( 'user_email', $author );
  5. $title = $post->post_title;
  6. $permalink = get_permalink( $ID );
  7. $edit = get_edit_post_link( $ID, '' );
  8. $to[] = sprintf( '%s <%s>', $name, $email );
  9. $subject = sprintf( 'Published: %s', $title );
  10. $message = sprintf ('Congratulations, %s! Your article ā€œ%sā€ has been published.' . "\n\n", $name, $title );
  11. $message .= sprintf( 'View: %s', $permalink );
  12. $headers[] = '';
  13. wp_mail( $to, $subject, $message, $headers );
  14. }
  15. add_action( 'publish_post', 'post_published_notification', 10, 2 );
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22. function my_trash_action( $post_id ) {
  23. if ( 'custom_post_type' != get_post_type( $post_id )
  24. return;
  25. //Do Stuff....
  26. }
  27. add_action( 'trashed_post', 'my_trash_action' );
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34. add_action('before_delete_post', 'my_deleted_post');
  35. function my_deleted_post($post_id){
  36. wp_die(var_dump($post_id));
  37. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement