I have registered a shortcode on my site (check_usersrole) to return '1' if a string is found inside the user role array.
In a view, I want to display an icon if the value '1' is returned. I have confirmed that the shortcode is opertaing correctly by outputting the retunred value but when I try to use a conditional to display E when 1 isreturned, E does not appear.
I have registered the shortcode in the Toolset settings for third party shortcodes.
Is there something wrong with my syntax or is this not allowed?
I know the use of [wpv-user field='ID'] is working because if I include [check_usersrole user_id='[wpv-user field='ID']' checkfor='external'] in the content template, it will, when called by the view, produce 1s and 0s depending on whether each user's role includes "external". It just doesn't seem like the conditional is working even thought it includes the same code which it evaluates against.
Notice the many use of the single quotes in particular for the user_id. If you manually provide a user ID you will notice that the conditional still works.
Please try this as a test and let me know what happens. We may need to restructure this entire code.
I'm really sorry, I forgot that we made a subsequent change from the role of external to the role contributor so there are no users with the role external. I have changed the shortcode test and the conditional to reflect this now.
I've tried working on a solution for you, however you need to set all the users display name to their emails. This way we can use the display names to get there emails.
Take a look here hidden link As you can see i've created a custom code that only takes the [wpv-user] shortcode as input and I can return the ID just as a test inside the function.
So if you set all the display names to their emails then we can modify your function to only take the [wpv-user] shortcode as a parameter and then get the user's ID from that.
Please let me know what you think of this workaround.
I really don't want to use this as a workaround as I don't want to set display names to email addresses. Is there a reason why the enclosure of a Toolset shortcode in a custom one doesn't work?
As you can see the use of the multiple ' ' is closing the previous ones and opening again so the ID attribute for the field isn't being passed properly.
I hope this clears this up for you. This would happen with any shortcode when you're doing a 3 layer shortcode.