Skip Navigation

[Resolved] Unable to set cred_field value for email with usermeta

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

Problem: I would like to set the value of a cred_field with the value of an email custom field in the current User's profile. When I use the Types usermeta shortcode, the value is not set correctly. If I place the same types usermeta shortcode outside the CRED field, I see the correct email address.

Solution: The Types usermeta shortcode will output a full HTML email address link, which won't work in a cred_field value attribute. Instead, you should use the wpv-user shortcode to output only the email address:

<div class="form-group">
<label>Contact Email</label>
[cred_field field='eoi-contact-email' post='expression-interest' value="[wpv-user field='wpcf-contact-email-universal']" urlparam="" class='form-control' output='bootstrap']
</div>

Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/functions/#email
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-user
https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_field

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

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 2 replies, has 2 voices.

Last updated by jamesH-10 6 years, 1 month ago.

Assisted by: Christian Cox.

Author
Posts
#621749

I am trying to:

Set the value property of a cred_field using usermeta data for the email address

Link to a page where the issue can be seen:

Dev site I'd rather not disclose publicly.

I expected to see:

Email address as the field value.

Instead, I got:

The filed name (Contact Email) is set as the value.

This is the shortcode I am using:

[cred_field field='eoi-contact-email' post='expression-interest' value="[types usermeta='contact-email-universal' user_current='true'][/types]" urlparam="[types usermeta='contact-email-universal' user_current='true'][/types]" class='form-control' output='bootstrap']

(Not sure if urlparam should help but I put it in there for luck.

If I use the shortcode in the cred form elsewhere I get the correct value returned:

[types usermeta='contact-email-universal' user_current='true'][/types]

Returns:

blinky@bill.com

If I hardcode an email address into the value property I get the correct value:

[cred_field field='eoi-contact-email' post='expression-interest' value="blinky@bill.com" urlparam='' class='form-control' output='bootstrap']

#621879

Hi, the types field shortcode will return a fully formatted email link, which won't work as the value of a cred_field shortcode. Instead, you should use the wpv-user shortcode to return just the email address, and remove the urlparam value you added for now:

<div class="form-group">
<label>Contact Email</label>
[cred_field field='eoi-contact-email' post='expression-interest' value="[wpv-user field='wpcf-contact-email-universal']" urlparam="" class='form-control' output='bootstrap']
</div>
#621920

Thanks mate, that worked perfectly.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.