Custom Fields

Custom Fields is a premium add-on for Better Notifications for WP. You can purchase it here.

The Better Notifications for WP Custom Fields Add-on provides:

  • Custom field shortcodes and formatting
  • Custom field notifications

New Custom Field Shortcodes

You can include data from custom fields in your:

  • Post Notifications
  • Page Notifications
  • Custom Post Type Notifications
  • New User Registration Notifications

You can use custom field shortcodes in both the subject and message body of your notifications.
It works great with ACF’s front-end forms too (acf_form). Shortcodes can be used in the From Name, Email, and Reply To fields (where customising these fields are supported by WordPress).

New Custom Field Notifications

  • ‘Post’ Custom Field Updated – Trigger a notification when one or more custom fields are updated with any value.
  • ‘Post’ Custom Field Value Updated – Trigger a notification when a single custom field value changes to a specified value.
  • ‘Page’ Custom Field Updated
  • ‘Page’ Custom Field Value Updated
  • ‘Custom Post Type’ Custom Field Updated
  • ‘Custom Post Type’ Custom Field Value Updated
  • User Custom Field Updated
  • User Custom Field Value Updated

Formatting

You can format the output of some custom fields using the ‘type’ and ‘format’ shortcode parameters.

Supported field types are:

  • Checkbox / Radio Button (essentially anything that outputs an array)
  • URL
  • Attachment
  • Timestamp
  • Date

Supported Custom Field Plugins

The custom field plugins that are supported for posts, pages, or custom post types are:

Some parts of Toolset Types may work but it isn’t officially supported by this add-on and as such, support can’t be provided when using the BNFW Custom Fields add-on and Toolset Types.

User Profile Custom Fields

You can also include data from custom fields in a user’s profile (user meta data), providing that it’s created using WordPress’s standard user_meta_fields, either via ACF, WordPress, custom code, or another supported plugin. These can be used in any of the notifications that supports the set of User shortcodes.

This add-on also works great with the Conditional Notifications add-on.

Available Custom Fields

The custom field types that you can currently use in your post, page, and custom post type notifications are:

  • Text
  • Textarea
  • Number
  • Email
  • Password
  • WYSIWYG Editor
  • Image
  • File
  • Select
  • Checkbox
  • Radio Button
  • True / False
  • Taxonomy
  • Page Link
  • Color Picker
  • oEmbed

Please Note: Data is retrieved and displayed in the way that it is stored in the database but can be formatted using the type and format shortcode parameters, mentioned below.

Creating a Field Group and Fields in ACF

I’m going to presume you know how to create custom fields using ACF however, if you don’t, please follow the ‘Creating a Field Group’ documentation over on the ACF website.

If there are any particular custom fields that you’d like to use to ‘trigger’ a notification to be sent later on, make a note of their names. This is shown next to the label when editing a Field Group.

Screenshot 2015-12-22 14.21.01

Creating a Custom Field Notification

After installing and activating the new ‘BNFW  – Custom Fields Add-on’ plugin, go to Notifications > Add New in the sidebar of the WP Admin.

Setting up a notification here is just like setting up any other notification in BNFW except there are a few new options.
In the Notification For selection box, you’ll see new options under Posts, Pages, and any custom post types that you’ve got set-up. Select one of these to show the other custom field settings for this notification.

Screenshot 2015-12-22 14.39.42

Once you’ve done this, you can then choose which custom field(s) you’d like to use to ‘trigger’ the notification to be sent out in the Send when these Custom Fields are Updated selection box. This box will show all custom fields available on your site, not just the ones created in ACF.

Screenshot 2015-12-22 14.42.43

You can search through the list by typing in the box to narrow down your selection. If you don’t see the custom field that you’ve just created in the box, be sure to check your spelling. If you still don’t see it, you may have to populate the custom field first for it to show. Once you’ve selected your custom fields(s), you can then set-up the rest of the notification as you wish.

Custom Field Shortcodes

You can include the data stored in custom fields in the subject and message body of your notifications too. To do this, you’ll need to use a new shortcode:

1
[custom_field field="X" type="Y" format="Z"]

Just replace X with the custom field name that you noted down earlier.
E.g. If your custom field name was text_box, then your shortcode would read [custom_field field="text_box"].

Formatting

Valid ‘type’ and ‘format’ parameters that you can using within your shortcodes are:

array
Converts an array into string using a separator.
E.g. [custom_field field="X" type="array" format=" || "] will output an array of values such as: Option1 || Option 2 || Option 3

url
Outputs the <a> tag using the value in the meta as the URL.
E.g. [custom_field field="X" type="url" format="Click here"] will output a link with the text ‘Click here’: Click here

attachment-id
This handles cases where the meta value contains an attachment id and can be formatted as either a URL or output an image.
E.g. [custom_field field="X" type="attachment-id" format="url"] could output an image URL
E.g 2. [custom_field field="X" type="attachment-id" format="image"] could output an <img> tag.

timestamp
This handles cases where the meta value contains a Unix timestamp. The format should contain the PHP date format that will be used. The default value is Y-m-d but you can use any valid PHP date format string.
E.g. [custom_field field="X" type="timestamp" format="Y-m-d"] will output the timestamp in the format 2015-08-29.

date
This handles cases where the meta value contains a formatted date that PHP can interpret. The format should contain the PHP date format that will be used. The default value is Y-m-d but you can use any valid PHP date format string.
E.g. [custom_field field="X" type="timestamp" format="jS F, Y"] will output the date in the format 29th August, 2015.

Custom User Field Shortcodes

If you’d like to use a custom field from the recipients user profile in any BNFW notification that supports recipient user shortcodes, you’ll need to use this new shortcode:

1
[email_user_custom_field field="X"]

If you want to use a custom field from the post/page author’s profile in a notification, use this shortcode:

1
[user_custom_field field="X"]

If you’re using Toolset Types to create your custom user fields, you may need to prepend any of these with wpcf- in order for it to show properly. E,g.

1
[email_user_custom_field field="wpcf-X"]

Once you’ve added everything that you want to your notification, Save it and test it out.

Questions?

Still have a question? Ask me a pre-sales question here and i’ll gladly help.

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

SaveSave

Subscribe for BNFW News

Want to know when new add-ons or features are released? Sign up to the newsletter. No spam, ever. Unsubscribe at any time.

Please enter your name.
Please enter a valid email address.
Something went wrong. Please check your entries and try again.