Events Made Easy › Forums › How do I … › Using EME IF
- This topic has 4 replies, 2 voices, and was last updated 3 years, 1 month ago by Franky.
-
AuthorPosts
-
Fri 24 Sep 2021 at 13:20 #63234AnonymousInactive
Hi Franky,
What I’d like to do is hide certain events on the main events list using [eme_events] based on a users role.
I’ve already got this setup for booking forms, so when someone is logged in, if they don’t have a specific WordPress role that has been added to the event as an attribute they can’t book onto the event and are shown a message stating: code below.
[eme_if tag='#_USER_HAS_ROLE{#_ATT{role}}' value='1'] #_SEATS <table class="eme-rsvp-form"> <tbody> <tr> <th scope="row">First Name*:</th> <td>#REQ_FIRSTNAME</td> </tr> <tr> <th scope="row">Last Name*:</th> <td>#_LASTNAME</td> </tr> <tr> <th scope="row">E-Mail*:</th> <td>#_EMAIL</td> </tr> </tbody> </table> [/eme_if] [eme_if tag='#_USER_HAS_ROLE{#_ATT{role}}' value='0']<strong>You are unable to book a place on this event.</strong>[/eme_if]
What I’d like to do is, using the [eme_events] shortcode, apply the same logic and only show events that people are able to book a place for based on their WordPress role, hiding any that they’re unable to book a space for.
I can’t seem to get it working, so thought I’d best ask if this is possible?
Thanks,
David,Fri 24 Sep 2021 at 16:33 #63236FrankyKeymasterReason is that in the form the #_ATT value is replaced and later on all the other generic placeholders (like #_USER_HAS_ROLE) when the event-part of the code is executed.
However for events the logic was coded differently, since there first the generic placeholders are replaced (which is #_USER_HAS_ROLE) and just after that #_ATT and all other event placeholders.
Now: switching the replacement will not solve the problem too: some people want to use generic placeholders inside #_ATT (and even more: when you have event custom fields then that replacement happens later on too).
So it is not an easy one 🙂 For now: try to use a fixed role and not via another variable, unfortunately that’s all I can offer. I’ll take a look but no promises at all.Wed 29 Sep 2021 at 16:34 #63255AnonymousInactiveThanks Franky.
I think I’ve got it working with a fixed role. I can’t really use it in production though as the site has around 15 possible user roles!
No problem at all, really appreciate you taking a look.
Wed 29 Sep 2021 at 19:45 #63258FrankyKeymasterThis change might help:
https://plugins.trac.wordpress.org/changeset/2606926/Thu 30 Sep 2021 at 09:54 #63259FrankyKeymasterCorrection: that change *will* help 🙂 But it will be in the next version too.
-
AuthorPosts
- The forum ‘How do I …’ is closed to new topics and replies.