The Better Notifications for WordPress Custom Fields Add-on (BNFW CF) allows you to do two things:
- Use custom fields for posts, pages, and custom post types in your notifications.
- 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. It works great with ACF’s front-end forms (acf_form) too.
Supported Custom Field Plugins
The custom field plugins that are supported for posts, pages, or custom post types are:
- Advanced Custom Fields Pro
- Advanced Custom Fields (Free)
- WordPress’s own, default custom fields
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 plugin. These 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 user custom fields have not been saved by WordPress by the point that these notifications are sent.
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:
- WYSIWYG Editor
- Radio Button
- True / False
- Page Link
- Color Picker
Please Note: Data is retrieved and displayed in the form that it is stored in the database. E.g. Dates are displayed in YYYYMMDD format, files are outputted as IDs and not full URLs, etc.
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.
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.
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.
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:
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 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:
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 the point that these notifications are sent.