WP Job Manager Emails – sMyles Plugins https://plugins.smyl.es WordPress and WHMCS Plugins Tue, 02 Sep 2025 21:17:53 +0000 en-US hourly 1 https://wordpress.org/?v=4.6.29 Emails IF Shortcodes (Nested, Comparison, Operators, etc) https://plugins.smyl.es/docs-kb/emails-if-shortcodes-nested-comparison-operators-etc/ Tue, 16 Oct 2018 17:19:17 +0000 https://plugins.smyl.es/?post_type=bwl_kb&p=161707 IF Shortcodes

All WP Job Manager Emails documentation can be found in the Help tab when editing an email template.

https://plugins.smyl.es/release-announcements/wp-job-manager-emails-2-7-0-email-preview-nestedconditional-if-pm-and-sq-plugin-support-and-more/

Included with the 2.7.0 release of this plugin is also a long overdue enhancement to the standard [if] shortcode from earlier releases.  I’ve been working on these features for a while now, and finally worked out the majority of the bugs and issues to be able to include it in this release.

All of the screenshots below are from the Help tab of your site (top right corner) when editing an email template

Attributes/Modifiers

IF shortcode attributes and modifiers

IF shortcode attributes and modifiers

Attributes and modifiers addition to the [if] shortcode now make it possible to combine multiple statements into  one, as well as doing specific comparisons on values with numerous different comparison operators (see below).

You can negate a statement by prepending an exclamation (!) point before the meta key, which basically means “NOT”, using comparisons or any of the other different combinations possible.

You can combine statements together to evaluate that ALL expressions are true, using the AND operator
You can combine statements together to evaluate that ANY expressions are true, using the OR operator

Nested IF Statements

Nested IF Statements

Nested IF Statements

Unfortunately due to the way that WordPress parses shortcodes, it’s not possible to nest a shortcode inside of the same shortcode, and in previous versions you could not create if statements, inside of other if statements.

With this release nested if shortcodes are now available, [if_1][if_2][if_3][if_4][if_5][if_6][if_7][if_8]

So when you need to nest an if statement inside of another one, just increase the number on the shortcode, and you’re good to go!  Please note that your [else] and closing [if] must match the opening [if].  For example, this would be a correct nested [if] shortcode statement:

[if job_location]
    Has a job location!
    [if_2 job_title]
        [job_title]
    [else_2]
        No job title
    [/if_2]
[else]
   No job location, so i'm not showing the title
[/if]

IF Comparison Operators

IF Shortcode Comparison Operators

IF Shortcode Comparison Operators

Comparison operators can be used to customize how the [if] shortcode will determine what to output.  Previous versions did not have this feature, and would only check if there was a value.

Now you can use the new comparison operators to check if a value contains a specific string, if it equals a specific string, starts (or ends) with a string, as well as arithmetic operators such as Less Than, Greater Than, and so on!

These arithmetic operators can also be used on multiple value (and taxonomy) field types to check the number of values in that field (explain more in detail below).

Like all other documentation, you can find examples, and more details in the Help tab while editing an email template.

IF for Taxonomies and Multiple Value fields

IF Shortcode Taxonomies and Multiple Value Field Types

IF Shortcode Taxonomies and Multiple Value Field Types

When a field you want to use an [if] shortcode on is a taxonomy or a multiple value field type (multiselectfile, etc), there is an easy way to check for a specific value, or even check all the values.

As mentioned above,  when using an arithmetic operator on these types of fields, it does not check the value itself, but checks the number/amount of values.

When you need to check for a specific value, or check all the values, you can use one of the available comparison operators (such as CONTAINS or EQUALS ), but instead of just entering one value, you can separate each value using a comma , (which is also known as CSV or comma separated values).

]]>
Adding custom plugin or theme email templates https://plugins.smyl.es/docs-kb/adding-custom-plugin-or-theme-email-templates/ Mon, 21 Nov 2016 00:40:42 +0000 https://plugins.smyl.es/?post_type=bwl_kb&p=120430 One of the new great features included with the WP Job Manager Emails 2.0 plugin is the Email Templates feature!

Email Templates Modal

Email Templates Modal

Email Templates Modal Preview

Email Templates Modal Preview

The new email templates feature allows users to select from any of the included (or added by themes, plugins, or your own custom code) templates, to help kickstart creating emails with ease.  The core plugin includes 33+ email templates (as of 2.0.0) which include custom ones I created, as well as, default emails sent by the core plugins, converted into templates.

If you’re a theme or plugin developer (or individual developer), you may want to include your own templates, which is very easy to do, and below I will show you exactly how to do this.

Adding Custom Templates

This tutorial is a little rough right now (very rough we will say), and will be updated soon with more details, a clear example, and references to available hooks, and shortcodes.  For now here’s the PHPDoc block for the filter:

functions.php

/**
 * Filter to add Custom Theme, or Plugin templates
 *
 * If you want to add custom templates, this is the hook you should use.
 * Custom templates should follow the pattern below.  Templates should be placed inside the 'templates' array key
 * which is an array of non-key arrays.
 *
 * For the email template post content, you should NOT use HTML as this will be stripped if the user sets the email type
 * to plain text.  Instead, you should use new line breaks (n), which will be converted to HTML <br> automatically.
 *
 * Supported shortcodes (NOT WordPress shortcodes, this plugins shortcodes) can be used in almost every field (to, subject, post_content),
 * except post_title.  If you want to add custom shortcodes, @see WP_Job_Manager_Emails_Shortcodes
 *
 * The `action` value in the template array of arrays should be the action to associate the template with.
 * This is the key of the action/hook, defined in this class, or extending classes @see init_ps_actions() @see init_actions()
 *
 * @see https://plugins.smyl.es/docs-kb/adding-custom-plugin-or-theme-email-templates/
 *
 * @since 2.0.0
 *
 * @param array $templates    Array of templates based on active/available hooks
 * @param array $ps_actions   Array of Post Status actions/hooks
 * @param array $core_actions Array of Core actions/hooks
 * @param class $this         Access to $this current object
 */
add_filter( 'job_manager_emails_hook_templates', 'smyles_test_email_templates', 10, 4 );

function smyles_test_email_templates( $templates, $ps_actions, $core_actions, $that ){

	$singular = 'Listify Listing';

	$content = '';
	$content .= __( 'Hello' ) . "n" . "n";
	$content .= sprintf( __( 'A new %1$s has just been submitted by *%2$s*.  The details are as follows:' ), $singular, '[company_name]' ) . "n" . "n";
	$content .= __( 'This is a custom email template just for the Listify theme!  Plugin and theme developers can easily add their own templates! ') . "n" . "n";
	$content .= "[divider]" . "n" . "[job_fields]" . "n" . "[/divider]" . "n" . "n";
	$content .= "[job_description]" . "n" . sprintf( __( 'The %s description is as follows:' ), $singular ) . "n" . "[/job_description]" . "n" . "n";
	$content .= sprintf( __( 'You can view this %1$s here: %2$s' ), $singular, '[view_job_url]' ) . "n";
	$content .= sprintf( __( 'You can view/edit this %1$s in the backend by clicking here: %2$s' ), $singular, '[view_job_url_admin]' ) . "n" . "n";

	$templates['listify'] = array(
	       'label'     => __( 'Listify Theme Templates' ), // Header text when viewing tab
	       'tab'       => __( 'Listify' ), // Text used for tab .. KEEP THIS SHORT!!
	       'desc'      => __( 'Themes and plugins can add their own custom templates!' ), // Description shown under header text
	       'templates' => array(
	               array(
		               'label'   =>  __( 'New Listify Listing Submitted' ),
		               'desc'    => __( 'This is a custom template specifically for the Listify theme integrated easily with only a few lines of code!' ),
	                   'action'       => 'job_manager_job_submitted',
	                   'attachments'  => array('company_logo'),
	                   'defaults' => array(
		                   'to' => '[admin_email]',
		                   'post_content' => $content,
		                   'subject'      => __( 'New Listify Submission, [job_title]' ),
		                   'post_title'   => __( 'New Listify Listing Submitted' ),
	                    )
	               )
	        )
	    );

	return $templates;
}

Below you can find links to the private GitHub repo for referenced methods and more information.  If you do not have access to the private repo and are a theme or plugin developer, please contact me, otherwise you can look at the URL to determine the file to look at, and the line numbers.

The filter above:

https://github.com/tripflex/wp-job-manager-emails/blob/master/includes/class-hooks.php#L587-L635

init_ps_actions :

https://github.com/tripflex/wp-job-manager-emails/blob/master/includes/hooks/class-poststatus.php#L100

Job init_actions :

https://github.com/tripflex/wp-job-manager-emails/blob/master/includes/hooks/class-job.php#L46

Resume init_actions :

https://github.com/tripflex/wp-job-manager-emails/blob/master/includes/hooks/class-resume.php#L92

]]>