Send mail notification to admin for update in lms content

Add the given code in your wplms-customizer.php file at the end before ” ?> ” in wplms customizer plugin .

function wplms_updated_send_email( $post_id ) {

// If this is just a revision, don't send the email.

if ( wp_is_post_revision( $post_id ) )

 

return;

// post type quiz ,question,assignment,unit

 if( get_post_type( $post_id ) == 'question' ||  get_post_type( $post_id ) == 'course' || get_post_type( $post_id ) == 'wplms-assignment' || get_post_type( $post_id ) == 'quiz' ||  get_post_type( $post_id ) == 'unit' ){

    $post_title = get_the_title( $post_id );

    $post_url = get_permalink( $post_id );

    $subject = 'A post has been updated';

    $message = "A post has been updated on your website:\n\n";

    $message .= $post_title . ": " . $post_url;

    // Send email to admin.

    wp_mail( '[email protected]', $subject, $message );

 }

}

add_action( 'edit_post', 'wplms_updated_send_email' );

NOTE : Change the [email protected] to your email .

Was this article helpful?

Leave A Comment?