Custom Fields

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

The Better Notifications for WordPress Custom Fields Add-on (BNFW CF) allows you to do two things:

  1. Use custom fields for posts, pages, and custom post types created using Advanced Custom Fields (ACF) in your notifications.
  2. Use custom user fields from a user’s profile in any BNFW notification that allows you to use the user shortcodes except for the registration notifications.

It provides a number of new shortcodes allowing you to include data from custom fields in both the subject and message body of your notifications. It also allows you to set one or multiple custom fields that will ‘trigger’ the notification and cause it to be sent. Both the latest versions of the Free and Pro ACF plugin are supported. It 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

You can also include data from custom user profile fields (user meta data), providing that it’s created using WordPress’s standard user_meta_fields, either via ACF, WordPress, custom code, or another plugin. These can be used in any notification that allows you to use the user shortcodes that BNFW provides.

Please Note: Data is retrieved and displayed in the form that it is stored in the database by ACF. E.g. Dates are displayed in YYYYMMDD format, files are outputted as IDs and not full URLs, etc.

Creating a Field Group and Fields

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 for 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:

[custom_field field=”X”]

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”].

Custom User Field Shortcodes

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

[user_custom_field field=”X”]

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

This shortcode can be used in any of the notifications that supports the set of User shortcodes except for the New User Registration and Post-registration Email notifications because the custom fields have not been saved by WordPress by this point.

ACF Front-end Forms

As of BNFW v1.6.3, ACF front-end form (acf_form) functionality works as expected.