Skip Navigation

[Resuelto] Conditional Statement with Custom User Field

This support ticket is created hace 4 años, 2 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Este tema contiene 1 respuesta, tiene 1 mensaje.

Última actualización por Darryl hace 4 años, 2 meses.

Autor
Mensajes
#1786525

I have a custom user field and I would like to compare the value from the current user with the post-id of the current post in a conditional statement.

[code]
[types usermeta='member-employer-connection' current_user='true'][/types] - [wpv-post-id]
[wpv-conditional if="( '[types usermeta='member-employer-connection' current_user='true'][/types]' eq '[wpv-post-id]' )"]
They are the same
[/wpv-conditional]
[/code]

The first line just shows the value of the custom user field for the current user and the current post's id so I can see if they're the same.

I based what I'm doing off a post by Minesh here: https://toolset.com/forums/topic/conditional-display-based-on-custom-user-field/
I have a user loop where I used Minesh's code to see if the user field was empty or not and that worked fine.

Now I want to see if the custom user field for the currently logged in user matches the post id of the currently viewed post.

#1786655

In my conditional statement, I had a form that my test user did not have access to. I changed the access on the form and it worked 🙂