Hi @lucein,
Thanks for your message.
Please can you post a link to two screenshots: one showing the notification being edited in BNFW, and another showing the resulting email? This should help me to diagnose the issue.
Thread Starter
lucein
(@lucein)
Hi @lucein,
Thanks for sending these.
Firstly, I can see that some of the shortcodes aren’t correct based on the available shortcodes found on this page: https://betternotificationsforwp.com/documentation/notifications/shortcodes/?notification=user-login
Secondly, the [cf_geo] related shortcodes, unless they’re custom shortcodes that you’ve created via this method, won’t work natively in BNFW – the only shortcodes that work in BNFW notifications are the ones supplied by BNFW.
Thirdly, it’s worth checking the ‘Text’ tab of the notification editor to ensure that all characters look correct and aren’t being changed/encoded/wrapped in additional HTML in some way. This can sometimes happen when copying and pasting from another source.
Let me know if any of the above helps.
Thread Starter
lucein
(@lucein)
Hello @voltronik,
I created a function as your page describes. To just insert the current year in the footer of the email.
FYI, the example you give for a custom short code has errors in the example. You have it as:
function bnfw_shortcode_futuredate() {
$future_date = date( 'F j, Y', strtotime( '+1 year' ) );
return $future_date;
}
add_shortcode( 'future_date', 'bnfw_shortcode_futuredate' );
}, 1, 1 );
With extra. } and ,1, 1); Seems to be an minor oversight in your documentation, I believe you meant this only for 2nd example when inserting using your Addon via the add filter. As Shortcode with extra character generates a critical error because of the typo.
Removing the extra characters from the shortcode, removes the critical error.
Once I added the add_filter line to the functions file. The custom shrotcode current year and [cf_geo]shortcodes started rendering correctly in the emails.
add_filter( 'wp_mail', function( $args ) {
$args['message'] = do_shortcode( $args['message'] );
return $args;
}, 1, 1 );
You probably should make that clearer that you must add the “add_filter” line to get any custom short code to render in BNFW emails.
Thanks for your help.
Hi @lucein,
Thanks for reporting this – I’ve updated the documentation to reflect your feedback.
I’m glad you now have the shortcodes working.
Please let me know if you need anything else.