Skip Navigation

[Resolved] Notification to specific e-mail address with custom field value in Message Body

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to use the value of a User Form custom field as the email destination for a Forms notification.

Solution: Access the custom field value using the User ID placeholder:

[types usermeta='mesto-obec' user_id='%%USER_USERID%%'][/types]

Relevant Documentation:
https://toolset.com/documentation/user-guides/cred-user-forms-email-notifications/#inserting-the-user-login-information-fields

This support ticket is created 6 years, 3 months 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 4 replies, has 2 voices.

Last updated by jiriK-2 6 years, 3 months ago.

Assisted by: Christian Cox.

Author
Posts
#1071522

Hello,

I've build Toolset User Form following your documentation.

Now I need to send a Notification e-mail message to a specific e-mail address (not any user's email address) with custom fields.

So for instance in Content User Form I have my Custom field e. g.:

<div class="form-group">
<label>Město, obec</label>
[cred_field field='mesto-obec' value='' urlparam='' class='form-control' output='bootstrap']
</div>

and now I need send sent a value of this field in Notification mail body to a specific email address.

I was trying to use:

[wpv-post-field name='mesto-obec'] - not working

[types usermeta='mesto-obec'][/types] - not working

[types usermeta='mesto-obec' user_is_author='true'][/types] - not working

Please let me know how to display the field's content properly.

Thanks, best,

Jiri.

#1071588

Hi, try adding the new User ID to the Types field shortcode like this:

[types usermeta='mesto-obec' user_id='%%USER_USERID%%'][/types]

That should give you access to the custom field value in a notification.
https://toolset.com/documentation/user-guides/cred-user-forms-email-notifications/#inserting-the-user-login-information-fields

#1071640

Dear Christian,

perfect, it is working now, thank you very much!

The last issue:

I also use these 2 default user fields:

<label>Jméno</label>
[cred_field field='first_name' post='user' value='' urlparam='' class='form-control' output='bootstrap']
</div>

<div class="form-group">
<label>Příjmení</label>
[cred_field field='last_name' post='user' value='' urlparam='' class='form-control' output='bootstrap']
</div>

and theis value's displaying is not working in your suggested way:

[types usermeta='first_name' user_id='%%USER_USERID%%'][/types]
[types usermeta='last_name' user_id='%%USER_USERID%%'][/types]

Please how to display them properly in Notification mail body to a specific email address?

Many thanks!

Jiri

#1071674

There aren't built-in placeholders for first and last name, but you can add this custom code to your child theme's functions.php file to activate custom placeholders:

add_filter('cred_body_notification_codes', 'custom_generic_field_notification');
add_filter('cred_subject_notification_codes', 'custom_generic_field_notification');

function custom_generic_field_notification( $defaultPlaceHolders ) {
  $newPlaceHolders = array(
    '%%FORCED_FIRST%%' => $_REQUEST['first_name'],
    '%%FORCED_LAST%%' => $_REQUEST['last_name'],
  );

  return array_merge($defaultPlaceHolders, $newPlaceHolders );
}

Then in the notification you can use the placeholders %%FORCED_FIRST%% and %%FORCED_LAST%% to display the first and last name.

#1072483

Dear Christian,

great, everything is working fine now, thanks for your help! 🙂

Jiri