Job Alerts snippets

← Back to Job Alerts

Note: All code examples on this site are provided for developer reference/guidance only and we cannot guarantee that they will always work as expected. Our support policy does not include assistance with modifying or debugging code from any code examples, and they may be changed or removed if we find they no longer work due to changes in our plugins.Please use the Code Snippets plugin, rather than adding the code samples below directly to your theme’s functions.php file. That will help ensure that any code errors won’t crash your site, and the changes will not be overwritten when you update your theme.


Add a custom email frequency for WPJM Job Alerts

The following example will add a new frequency “Monthy” for WPJM Job Alerts.

function htdat_job_manager_alerts_alert_schedules ( $schedules ) {
    $schedules['monthly'] = array(
        'interval' => 86400 * 30,
        'display'  => __( 'Monthly', 'wp-job-manager-alerts' )
    );

    return $schedules;
}

add_filter('job_manager_alerts_alert_schedules', 'htdat_job_manager_alerts_alert_schedules');

Change the From: name in the Job Alert notification

 function job_manager_alerts_mail_from_name_dm () {
 		return "Add From Name Here";   
 }

add_filter('job_manager_alerts_mail_from_name', 'job_manager_alerts_mail_from_name_dm');

Change the subject of the Job Alert notification email

function job_manager_alerts_mail_subject () {
    return "New Email Subject";
}

add_filter('job_manager_alerts_subject', 'job_manager_alerts_mail_subject');

Enable HTML formatting in the Job Alert email

add_action( 'job-manager-alert', 'wpjm_alerts_html_email_on', 5 );
add_action( 'job-manager-alert', 'wpjm_alerts_html_email_off', 15 );
add_filter( 'job_manager_alerts_template', 'wpautop', 90 );

function wpjm_alerts_html_email_on() {
	add_filter( 'wp_mail_content_type', 'wpjm_alerts_html_email_type' );
}

function wpjm_alerts_html_email_off() {
	remove_filter( 'wp_mail_content_type', 'wpjm_alerts_html_email_type' );
}

function wpjm_alerts_html_email_type() {
	return 'text/html';
}