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
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']
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?
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.
Excellent - many thanks for your help - that works.
Yes, it should be a hyphen not an underscore!