Skip to content

Instantly share code, notes, and snippets.

@tripflex
Created October 18, 2022 22:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tripflex/e6aec912b0e3145adec10d308c13918b to your computer and use it in GitHub Desktop.
Save tripflex/e6aec912b0e3145adec10d308c13918b to your computer and use it in GitHub Desktop.
Prevent specific email templates from sending when the user is an administrator
<?php
add_filter( 'job_manager_emails_email_should_send', 'smyles_email_should_send', 10, 4 );
function smyles_email_should_send( $should_send, $template, $listing_id, $that ) {
// Don't send if the user IS an admin submitting the application
if ( $template->template_name && 'application_confirmation_non_admin' === $template->template_name && current_user_can( 'manage_options' ) ) {
return false;
}
// Don't send if the user IS NOT an admin submitting the application
if ( $template->template_name && 'application_confirmation_admin' === $template->template_name && ! current_user_can( 'manage_options' ) ) {
return false;
}
return $should_send;
}
@tripflex
Copy link
Author

You MUST set the "template name" under Advanced area when editing a template to:

application_confirmation_non_admin - email to send when user is NOT an admin
application_confirmation_admin - email to send when user IS an admin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment