Skip Navigation

[Resolved] Email Variables work in test email and are blank coming from the live site

This support ticket is created 4 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 2 replies, has 2 voices.

Last updated by nabilS-3 4 years ago.

Author
Posts
#1833417

Tell us what you are trying to do?
We are using WP Mail SMTP and using SendInBlue for our email delivery. Site is hosted on Pantheon.io

In Toolset we have a user fill out a registration form and pick being a Peer or a Clinician. When the form is completed, an email will go to the site admin to let them know to approve the new user. In this email we have variables for showing the new user's first name, last name, and email address.

When we use the Send a test email button inside of the Edit Post Form, the email shows the variables correctly (well it shows the default information). But when we test it through the site, the spot with the variables is empty. I can't pinpoint why it's not showing correctly in the live site. If we turn off the WP Mail SMTP then none of the emails get through at all.

Is this something we are doing wrong in Toolset? Or is something else blocking the variables?

Here is the code for the email portion:

A Peer Support Provider submission is ready for your review. Please log into Redline Rescue, review this entry.

First Name: [wpv-user field="user_firstname" user_id="%%USER_FIRSTNAME%%"]
Last Name: [wpv-user field="user_lastname" user_id="%%USER_LASTNAME%%"]
Email Address: [wpv-user field="user_email" user_id="%%USER_EMAIL%%"]

hidden link" target="_blank">View Submission

Here is the partial code for the form editor (showing just the top part that I believe is the relevant part):

[credform]
<div class="form-group">
<label>First Name: </label>
[cred_field field='peer-first-name' force_type='field' class='form-control' output='bootstrap']
</div>
<div class="form-group">
<label>Last Name: </label>
[cred_field field='peer-last-name' force_type='field' class='form-control' output='bootstrap']
</div>
<div class="form-group">
<label>Cell Number: </label>
[cred_field field='phone-number' force_type='field' class='form-control' output='bootstrap']
<p>Do you consent to this number being utilized as a direct point of contact for representatives of Redline Rescue: </p>
[cred_field field='phone-contact-consent' force_type='field' class='form-control number' output='bootstrap']
</div>
<div class="form-group">
<label>Email: </label>
[cred_field field='email' force_type='field' class='form-control' output='bootstrap']
</div>

I have dug through the forums and watched tutorials and have yet to figure this issue out. Thanks for any help.

What is the link to your site?
hidden link

#1834085

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

In the notifications you can use placeholders (e.g. %%USER_LASTNAME%%) to output some of the standard user fields, but looking at your form you are not using the standard fields for first name, last name, email etc.

Here are the defaults in a new registration form for those fields:

	<div class="form-group">
		<label>[cred_i18n name='user_email-label']Email[/cred_i18n]</label>
		[cred_field field='user_email' class='form-control' output='bootstrap']
	</div>
	<div class="form-group">
		<label>[cred_i18n name='first_name-label']First name[/cred_i18n]</label>
		[cred_field field='first_name' class='form-control' output='bootstrap']
	</div>
	<div class="form-group">
		<label>[cred_i18n name='last_name-label']Last name[/cred_i18n]</label>
		[cred_field field='last_name' class='form-control' output='bootstrap']
	</div>

Note that the field slugs are "user_email", "first_name", and "last_name".

In your form the field slugs are "email", "peer_first_name", and "peer_last_name".

So you are using custom user fields, not the standard fields, hence those placeholders such as %%USER_LASTNAME%% can't be used to output your custom user field values.

And actually, you are doing it wrong anyway, because to output the standard Last Name you would simply use %%USER_LASTNAME%% directly, and in your case you are trying to use them as user_id attributes in your shortcodes.

In this example here you are not even outputting your custom user fields, you are trying to output the standard fields via shorcode, but the shortcodes are broken because you pass the placeholders as user_id attributes:

First Name: [wpv-user field="user_firstname" user_id="%%USER_FIRSTNAME%%"]
Last Name: [wpv-user field="user_lastname" user_id="%%USER_LASTNAME%%"]
Email Address: [wpv-user field="user_email" user_id="%%USER_EMAIL%%"]

If you want to output the standard fields for last name etc. then just use the placeholders directly, e.g.

Last Name: %%USER_LASTNAME%%

If you want to output your custom user fields, then use the shortcodes but include the user_id attribute like so:

Last Name: [types usermeta='peer-last-name' user_id='%%USER_USERID%%'][/types]

(That types shortcode to output a user custom field can be inserted using the Fields and View button in the notification editor, but you need to add the user_id attribute manually.)

I think the first thing you need to do is decide whether you are using the standard WordPress fields for first name, last name, and email and whether you need custom fields for those at all, and once you decide that you can use the above to determine how to use those fields in the notifications.

Hopefully that helps. I realise it is not the easiest of things to implement, and it is on our to-do list to improve the usability of these features.

#1839321

My issue is resolved now. Thank you for the help.