Skip to content

Instantly share code, notes, and snippets.

@tripflex
Created July 4, 2018 03:08
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/bd42d1360e1e4f07003667e1423dcddb to your computer and use it in GitHub Desktop.
Save tripflex/bd42d1360e1e4f07003667e1423dcddb to your computer and use it in GitHub Desktop.
Only send email for anonymous users when using WP Job Manager Emails
<?php
// ^ There should ONLY be one of these at the top of child theme's functions.php file
add_filter( 'job_manager_emails_email_should_send', 'smyles_wpjm_emails_only_send_for_anon_users', 10, 4 );
// You MUST configure the "template name" under the advanced settings area, and set it to "job_email_example_send_anon_only",
// or whatever custom email template name you decide to use. Each template must have a unique name
function smyles_wpjm_emails_only_send_for_anon_users( $should_send, $template, $listing_id, $that ) {
if ( $template && $template->template_name && $template->template_name === 'job_email_example_send_anon_only' ) {
if ( is_user_logged_in() ) {
return false;
}
}
return $should_send;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment