I have a user field called phone. I want to be able to determine if that field is empty for the author of the current post.
I currently have this:
[wpv-conditional if="( '[wpv-user field='wpcf-phone']' ne '' )"]
my content
[/wpv-conditional]
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Ian,
Thank you for contacting our support forum.
You can try this code below.
[wpv-conditional if="( '[wpv-user field='wpcf-phone' id='[wpv-post-author meta='ID']']' ne '' )"]
my content
[/wpv-conditional]
PLease that and let me know if it helps.
Thanks,
Shane
The phone field is filled out and there should be an icon showing up before it but nothing is showing up. Here is my code
<div class="vendor-profile">
[wpv-conditional if="('[wpv-user field='wpcf-phone' id='[wpv-post-author meta='ID']']' ne '' )"]
<div class="vendor-icon"><i class="fas fa-phone fa-lg" title="Vendor Phone Number"></i></div>
[/wpv-conditional]
<div class="vendor-phone">[types usermeta="phone" user_is_author="true"][/types]</div>
</div>
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Ian,
Would you mind providing me with a link to this page so that I can have a look ?
The private fields have been enabled for your next response.
Thanks,
Shane
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Ian,
It should now be working.
The correct shortcode shouldve been [types usermeta="phone"][/types]
Thanks,
Shane
OK something a little more complex. This is not showing up even when the field is filled out. The link works correctly without the conditional statement.
[wpv-conditional if="('[types usermeta="facebook-url"][/types]' ne '' )"]<a class="vendor-link vendor-facebook" href="[types usermeta='facebook-url' output='raw' user_is_author='true'][/types]" target="_blank" ><i class="fab fa-facebook-square fa-2x" title="Facebook"></i></a>[/wpv-conditional]
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Ian,
It seems that the conditionals are not working at all with the user field.
Would it be possible if I got a local copy of your site to test this further ?
Thanks,
Shane
I can do that. I could package it with Backup Buddy.
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Ian,
Sorry for the delay in response, but I could install the duplicator plugin and create the backup using that to test locally.
Please let me know if I can.
Thanks,
Shane
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Ian,
I was able to find the issue.
It seems it was the way you formatted the conditional shortcodes and a qoute was missing.
Could you use this as this should work.
[wpv-conditional if="( '[wpv-post-author format='meta' meta='wpcf-facebook-url']' ne '' )" debug="true"]<a class="vendor-link vendor-facebook" href="[types usermeta='facebook-url' output='raw' user_is_author='true'][/types]" target="_blank" ><i class="fab fa-facebook-square fa-2x" title="Facebook"></i></a>[/wpv-conditional]
Also could you use this as an example going forward so that the conditionals work correctly.
Thanks,
Shane
Shane,
I implemented the shortcodes as you suggested and it is still not working. In fact none of my conditional statements are working, including the ones that were working previously.
The phone icon that should be showing up before the phone number is not working
The email and facebook links are not showing up below the phone number
The product listing that was working before under products is not working either
Not sure why some stuff has quit working
It would appear that shortcodes need to be inserted into DIVI text modules and not DIVI code modules. This is unfortunate as then some CSS specific to text modules need to be overriden.
One additional note, it would be great if it could be determined why this is not working in the code module. The text module adds auto paragraphs so you can not leave your code nicely formatted making editing much harder.