• 1.
     
  • 2.
    function deleted_post_notify_author( $post_id ) {
  • 3.
     
  • 4.
     
  • 5.
    	$post = get_post($post_id);
  • 6.
    	if($post->post_type != 'post'){
  • 7.
    	    return false;
  • 8.
    	}
  • 9.
    	$author = $post->post_author;
  • 10.
    	$author_name = get_the_author_meta( 'display_name', $author );
  • 11.
    	$link = 'https://www.cgartzone.com/submission-rules';
  • 12.
    	$image = 'https://www.cgartzone.com/wp-content/themes/hitmag-child/assets/images/sad-icon-01.svg';
  • 13.
     
  • 14.
    	if( current_user_can('administrator')) {
  • 15.
     
  • 16.
    		if( $post->post_status == 'pending' ) {
  • 17.
     
  • 18.
    			$title = $author_name.' ' . __('We are sorry to inform you that your artwork has been declined', 'dw-notifications'). ' '.$post->post_title;
  • 19.
     
  • 20.
    		} elseif ( $post->post_status == 'publish' ) {
  • 21.
     
  • 22.
    			$title = $author_name.' ' . __('We are sorry to inform you that your artwork has been deleted because did not reached after 4 days 100 views at least', 'dw-notifications'). ' '.$post->post_title;
  • 23.
     
  • 24.
    		} else {
  • 25.
     
  • 26.
    			$title = $author_name.' ' . __('We are sorry to inform you that all draft posts will be delete. if you want to publish your project click submit for review', 'dw-notifications'). ' '.$post->post_title;
  • 27.
     
  • 28.
    		}
  • 29.
    		
  • 30.
    		$notif = array('title'=>$title, 'link' => $link, 'image' => $image);
  • 31.
    		dwnotif_add_notification($author, $notif);
  • 32.
    	}
  • 33.
    }
  • 34.
    add_action( 'before_delete_post', 'deleted_post_notify_author' );
function deleted_post_notify_author( $post_id ) { $post = get_post($post_id); if($post->post_type != 'post'){ return false; } $author = $post->post_author; $author_name = get_the_author_meta( 'display_name', $author ); $link = 'https://www.cgartzone.com/submission-rules'; $image = 'https://www.cgartzone.com/wp-content/themes/hitmag-child/assets/images/sad-icon-01.svg'; if( current_user_can('administrator')) { if( $post->post_status == 'pending' ) { $title = $author_name.' ' . __('We are sorry to inform you that your artwork has been declined', 'dw-notifications'). ' '.$post->post_title; } elseif ( $post->post_status == 'publish' ) { $title = $author_name.' ' . __('We are sorry to inform you that your artwork has been deleted because did not reached after 4 days 100 views at least', 'dw-notifications'). ' '.$post->post_title; } else { $title = $author_name.' ' . __('We are sorry to inform you that all draft posts will be delete. if you want to publish your project click submit for review', 'dw-notifications'). ' '.$post->post_title; } $notif = array('title'=>$title, 'link' => $link, 'image' => $image); dwnotif_add_notification($author, $notif); } } add_action( 'before_delete_post', 'deleted_post_notify_author' );

Copy Code to Clipboard Raw

Sign-in or Create a Free Account.

Snippi uses Twitter or Facebook to register and create accounts. Registration will enable you to keep track of your snippets. We never spam your timeline or wall. Ever.

Sign-in with Facebook Sign-in with Twitter