This shortcode can be used to personalize the content in stories by showing user-specific data.
The shortcode supports most standard properties that can make sense to display (first name, last name, login, …) and it can also be used to render information from related usermeta, such as additional information gathered via form plugins for a user’s account.
Here is an example of how you could start a story that includes the subscriber’s first name, or a default where it is not available:
Dear [groups_newsletters_user key="first_name" default="Subscriber"],
We have great news, again! ...
In the above example, the shortcode will be replaced by the first name of the recipient, or by the word Subscriber.
The shortcode takes the following attributes:
key: The key indicates the desired property that should be displayed from the user’s data.
default: This is a string that is displayed when the desired key is not available or empty.
empty: This is a flag which indicates whether to replace an empty key value with the default string. Normally, if the value for the desired key is empty, the default will be displayed instead. If you set this flag to
"yes", the default will not be used and nothing would be shown instead.
Please note that for plain subscribers, i.e. those who do not have an account but simply have subscribed using their email address, none of the data is available. It makes sense to use a sensible default as shown in the example above to cover for these cases. Otherwise, where the placeholder is used, nothing would appear.
Accepted values for the
key parameter are:
Furthermore, usermeta keys are accepted as long as they contain string values.
When users view the corresponding story on the front end, they will also see their personalized version. So, the content that is displayed for newsletter subscribers will be the same as that in the email they receive.