Skip Navigation

[Resolved] Displaying CRED usermeta in Post Form

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

Problem: I would like to display the value of a User custom field inside a CRED form.

Solution: Use the wpv-user shortcode and include the 'wpcf-' prefix before the field slug:

User shortcode: [wpv-user field='wpcf-business_name']

Relevant Documentation: https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-user

This support ticket is created 7 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.

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)

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by julieP 7 years, 3 months ago.

Assisted by: Christian Cox.

Author
Posts
#561626

I've set up a user field called business name. I'm trying to display the contents of that field to the user when they create a CRED post form when logged in. I've tried using this:-

[wpv-user field='business_name' user_is_author='true']

but nothing is displayed. What am I doing wrong?

Thanks

#561735

I'm trying to display the contents of that field to the user when they create a CRED post form when logged in
I'm not quite clear what you want: do you want to display this field on the actual CRED form on the front-end of your site so it can be seen when the user is creating a post with CRED? Or on the post itself created by CRED? Whose business name should be displayed - the current logged in user, or the author of some post?

[wpv-user field='business_name' user_is_author='true']

The attribute user_is_author is not a supported attribute here:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-user

If you want to display the business name field for the current, logged-in user, there is no need for the user_is_author attribute. You can remove it:

[wpv-user field='business_name']

If you want to display the business name field for another user, you must pass in that user's ID as another attribute:

[wpv-user field='business_name' id='12345']
#561823
screenshot.JPG

Hi Christian

This is curious. I'm not sure where I got this from:

[wpv-user field='business_name' user_is_author='true']

so I tried taking the attribute out but still doesn't work.

I've thrown together a simple contact form to demonstrate the issue. The form is displayed to the user when they're logged in (they're creating a post and I want them to see on that form the contents of their custom user field, no-one else's). In the attached screenshot from left to right is the CRED form to show the user field, the wordpress user profile showing the user is logged in and the custom user field is populated and then the form on the frontend which the user is seeing (line 1 shows no output for the custom user field).

Any ideas?

#562066

Ah, I forgot that you must use the 'wpcf-' prefix with the wpv-user shortcode. Example:

User shortcode: [wpv-user field='wpcf-business_name']

Double check the slug to make sure it's an underscore instead of a hyphen.

#562249

Excellent - many thanks for your help - that works.

Yes, it should be a hyphen not an underscore!