Skip to content

Instantly share code, notes, and snippets.

@nikitasinelnikov
Created November 25, 2020 12:51
Show Gist options
  • Save nikitasinelnikov/c6c92e6e1035ad94ec7a673c7a0dd9ad to your computer and use it in GitHub Desktop.
Save nikitasinelnikov/c6c92e6e1035ad94ec7a673c7a0dd9ad to your computer and use it in GitHub Desktop.
JobBoardWP: Add custom email notification
add_filter( 'jb_email_notifications', 'add_my_own_notifications', 10, 1 );
/**
* Note: Please insert the email notification's template to your theme
* wp-content/themes/{your-theme-folder}/jobboardwp/emails/job_submitted_author.php
*
* 'job_submitted_author' is a email notification key. Please rename to your own unique key
*/
function add_my_own_notifications( $notifications ) {
$notifications['job_submitted_author'] = [
'key' => 'job_submitted_author',
'title' => __( 'Job submitted', 'jobboardwp' ),
'subject' => __( 'New Job Submission - {site_name}', 'jobboardwp' ),
'description' => __( 'Whether to send the job author an email when new job is posted.', 'jobboardwp' ),
'recipient' => 'user',
'default_active' => true,
];
return $notifications;
}
add_action( 'jb_job_published', 'send_my_own_email', 10, 2 );
function send_my_own_email( $job_id, $job ) {
$author = get_userdata( $job->post_author );
if ( ! is_wp_error( $author ) && ! empty( $author->user_email ) ) {
JB()->common()->mail()->send( $author->user_email, 'job_submitted_author', [
'job_id' => $job_id,
'job_details' => JB()->common()->mail()->get_job_details( $job ),
'view_job_url' => get_permalink( $job ),
] );
}
}
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
A new job has been submitted:
{job_details}
View job: {view_job_url}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment