Good day.
I have an author archive and display both WordPress and custom fields for any user (outside the loop).
I use a Shortcode called [archive-author-id] to return the ID for the current author.
I then display the fields using, for example:
[wpv-user field="description" id="[archive-author-id]"]
or
[types usermeta='pronouns' user_id='[archive-author-id]'][/types]
However, I am unable to evaluate if those fields are empty.
For example, the following does not work.
[wpv-conditional if="('[wpv-user field='description' id='[archive-author-id]']' ne '')"]
[wpv-user field='description' id='[archive-author-id]']
[/wpv-conditional]
Many Thanks
Gavin
Hi Gavin,
Please use the Types usermeta in the conditional like this:
[wpv-conditional if="('[types usermeta="description" output="raw"][/types]' ne '')"]The field has a value compared to a null string[/wpv-conditional]
I did not include the user_id. Please first add a static ID there to see if for a specific user it works or not.
You can learn more here:
https://toolset.com/documentation/legacy-features/views-plugin/checking-fields-and-other-elements-for-emptynon-empty-values/
Thanks.
Hi Christopher
Using this conditional works:
[wpv-conditional if="('[wpv-user field='description' id='1']' ne '')"]
[wpv-user field='description' id='[archive-author-id]']
[/wpv-conditional]
However, if I retrieve the user ID using a shortcode (which is registered and works), the conditional does not work.
e.g.
[wpv-conditional if="('[wpv-user field='description' id='[archive-author-id]']' ne '')"]
[wpv-user field='description' id='[archive-author-id]']
[/wpv-conditional]
Thanks
Gavin
Hi Gavin,
As the shortcode is something that you gave created, to make sure it will be understood by Toolset items you need to add it to Toolset.
In order for custom shortcodes to work with our Toolset Conditional shortcode you need to register the shortcode at Toolset -> Settings -> Frontend and under 3rd Party shortcode arguments you will add the name of your shortcode.
Thanks.
The shortcode is registered.
The initial problem still persists.
Hi there,
The only other thing that I have in my mind is the way you retrieved the user ID as the static version works.
Maybe it is the fact that you use some sort of a hook that is not triggered yet when the condition is used that is why it does not generate the ID at that time.
But I a not sure, I can take a look into that, I'd appreciate it if you could give me the URL/User/Pass of your WordPress dashboard after you make sure that you have a backup of your website.
It is absolutely important that you give us a guarantee that you have a backup so if something happens you will have a point of restore.
Make sure you set the next reply as private.
Also tell me which view and page I should check and where you added the user ID shortcode code.
Thanks.