I'm trying to create some content based a value in a custom user field. To get started i'm just testing for the existence of any content at all with this statement before i refine it for specific values. But nothing is displaying as true- Do i have the syntaxt correct
I'm using this in a user record view
[wpv-conditional if="( '[types usermeta="school-levels"][/types]' ne '' )"]
school has a level
[/wpv-conditional]
Hi there,
Retrieving a custom field is possible only in the context of a view.
I suggest that you add a test page and inside the page, use the block editor to add the view block.
Set the proper custom field as the source of the view and inside the view add the conditional block and set it with the wizard to whatever you need.
Then add a single field block to show the custom field.
If everything works ok click the Three Dots WordPress menu icon at the very top right section of the screen and select the "Code Editor" option and in the changed code you can see the generated shortcode which you can use.
Check the screenshot please.
For more information:
https://toolset.com/course-lesson/using-toolset-conditional-block/
Sorry Christopher, I wasn't clear enough here. This is in a view and im using the original views (not block)
Steve
Hi Steve,
The syntax of the conditional statement that you've shared seems correct.
Have you checked the output of the types field shortcode alone, without the conditional statement?
( i.e. [types usermeta="school-levels"][/types] )
I'll also recommend testing the conditional statement with the debugging turned on, to see the exact conditional evaluation that is being processed:
( ref: https://toolset.com/documentation/legacy-features/views-plugin/debugging-views-output/ )
[wpv-conditional if="( '[types usermeta="school-levels"][/types]' ne '' )" debug="true"]
school has a level
[/wpv-conditional]
I hope this helps and please let me know how it goes.
regards,
Waqar
It seem like the short code i needed is
[wpv-user field="school-levels"] not [types usermeta="school-levels"][/types]
And so the conditional like this works ok
[wpv-conditional if="( '[wpv-user field="school-levels"]' ne '' )" debug="true"]
school has a level
[/wpv-conditional]