Posted: May 14, 2017 at 7:21 pm
|
Hi there I’m running into a bit of problem with the multi-tickets (EE4). Events are being sold to members and non-members with different prices. I can see there is the ability to restrict tickets based on set capability. This is almost okay, but regardless of capability the default message that EE presents on the front end (if you can’t buy a ticket) is “is available to members only. On Sale”. Is it possible to change the messaging for this? The objective is to only allow a user to buy a ticket type if they have that capability. Because of the default message, if a member looks to buy the first ticket it still says “is available to members only. On Sale” which doesn’t make sense. I guess the best approach is to either change the message to something that is more generic, or ideally hide the message completely. However the “is available to members only.” part doesn’t have it’s own class or id, so i can’t hide with CSS. If it’s easier to just hide the text, could you please point me in the right direction to either change the file, or add in a class with a function. Many thanks for your help : ) |
Hi there, You can completely remove the tickets that users don’t have access to from the ticket selector if that is what you are looking to do? – http://take.ms/eJ8ub To do that you can add this snippet: https://gist.github.com/Pebblo/106393acd850cb83c3798c66a9c5a19a Just add that function to a Custom Functions Plugin on your site. |
|
|
Thanks Tony. I think i’m being a bit slow (it’s late in Australia). The link to the first function is great for logged-in users (showing tickets to those users with a defined capability set), but if you’re not logged-in you don’t see any pricing. This then led me to look at the additional link to this snippet https://gist.github.com/Pebblo/16a7dabb6a6d8f0f3d4370ccda06098b I can’t figure out though (getting tired) whether this snippet is designed to use the code exactly, or to only show the ticket relating to the capability assigned to a user role? I’ve done the later (with my own capabilities) with the intent to show non-member-prices to those with a ‘subscriber’ role, and member-pricing for those with a ‘member’ role. Is this how it should work? function tw_ee_hide_no_cap_tickets_from_logged_in_users( $return_value, $ticket, $max, $min, $required_ticket_sold_out, $ticket_price, $ticket_bundle, $ticket_status, $status_class) { $event = $ticket->get_related_event(); $cap_required = $ticket->get_extra_meta( ‘get_member_pricing’, true ); |
That function hide tickets that don’t have capabilities assigned to them from logged in users. So for example you have a ‘non-member’ ticket with no minimum capability. Then a discounted ‘member’ ticket with a minimum capability assigned. By default a logged in user would see both, the above removes the ‘non-member’ ticket for the logged in user, but NOT if you have the manage_options capability (meaning your an admin so should see everything for you can… well, be an admin 🙂 )
So all of your tickets have a minimum cap required? How are your tickets currently setup in the event? How do you want them to display to logged in users? How do you want them to display to non-logged in users? |
|
|
Hi Tony It doesn’t seem to be working for me at present. Can i just clarify what i add to the Ticket Capability Requirement for the member only ticket? Would it be ‘ee_ticket_cap_required’ and add this as a capability for the user role for members? Ultimately i need to; Let non-logged in users see both options (member ticket $10 and non-member $5) I’ve got a complete mental block, sorry. |
OK, let’s take a step back a second as that’s not how it works. Let me explain how the capabilities check works and see if that clarifies things at all. The capability that you set on your ticket can be literally anything, as long as the users you want to access that ticket, have that ticket assigned to their role/account. There are no specific EE capabilities checked for to allow/deny tickets to users and that’s very intentional as it allows the system to be used with almost ANY membership/user management type plugin out there (there are limitations but the idea is to allow for the most flexibility). The check done by Event Espresso literally just checks that the current user has the capability you have set in the field (if they are logged out they don’t have any capabilities). So let’s use a capability that’s available on every WP site as an example, The So why do we call it the minimum capability? Because capabilities can stack, it depends on your user management plugin if they do, and how they do but using S2 Member as an example: https://s2member.com/kb-article/s2member-rolescapabilities/ Notice how Level_0 has its own set of caps. Level_1 has Level_0’s caps + its own. Level_2 has Level_0’s and Level_1’s caps + its own. As in they stack up, the level above gets the lower levels + its own, meaning if you set a minimum caps of Make sense? How are you managing the users on the site? Manually adding your own capabilies to 2 roles or using a plugin?
You either have access to the ticket, or your don’t. So it will either display a message (or be removed using the snippet I provided) or be available for registration. So with the first snippet I provided, the only problem was that logged out users couldn’t see the ticket not available message? |
|
|
Hi Tony, Thanks for taking the time to walk me through this. I understand the roles and how they work, but i’m still not clear (or if i am clear it’s not working for some reason), sorry. The desired output; The second snippet states; https://gist.github.com/Pebblo/16a7dabb6a6d8f0f3d4370ccda06098b Example of how to hide tickets that do not have a capability assigned to them from logged in users, so logged in users will only see tickets that have a ‘minimum capability’ set on them they the user has on their account. This snippet checks for an event meta value ‘hide_no_cap_tickets’ from within the event before removing any tickets from view. I’ve written and re-written the next part a number of times, and confuse myself so i think maybe the approach of filling the blanks might help me. Ticket 1 (for non-members) – do i leave this one blank? User role capabilities. I assume i need to assign a custom capability to the user role, or use a capability that currently exists for the member user role, but not for a subscriber? Keeping things to the code for ease. If i give my member user role the capability of ‘ee_ticket_cap_required’ in theory they should see the member price (but not the non-member price)? Similarly if a user role doesn’t have that capability they won’t see the member price and by default they should see non-member price? If that’s true, I’m not seeing this being applied on my end – but i might be missing something critical. Sorry for hand holding me through this. Thanks for your patience : ) |
To be clear, It’s a safegaurd I added to the function to prevent someone simply installing that function and all of their tickets disappearing for their users. As you mentioned, that function removes tickets from view that don’t have a capability set, so what if you don’t have capabilities set up and install that plugin? Your other users (not the admin) can’t view ANY tickets but you may not even know that. So as a safetynet, that function checks for an EVENT custom meta field called Note that is added as event/post meta, NOT ticket meta (which is what the minimum capability is).
This is where it gets confusing, you want tickets that are both viewable to non-logged in users and logged in users? I’m not sure how that works?
It depends on the above question really.
So if you set the minimum capability for the ticket to be
So non-member prices are available to everyone? Logged in or not?
Sounds like you missing the event meta mentioned above. However it sounds like my snippets you are using are causing you more confusion than anything, you may be better completely removing the snippets and getting this working as closely as you can without the snippets, then we can work on getting it to work how you are trying to do now. Currently, it sounds much more confusing than it needs to be. |
|
|
It’s becoming clearer… What i mean by a non-logged user seeing both tickets, is that both tickets are visible, but only the non-member ticket is purchasable. I’ve removed the snippet and used a capability called ‘get_member_pricing’ which is only a capability on a member role. That works and provides the text The Member Ticket ($5.00 (AUD)) is available to members only. Meaning that a logged-in ‘subscriber’ will also see there are 2 tickets available, but only one being purchasable (as above) which is perfect too. Where i needed the help is that for ‘members’ they have the capability to buy the $5 member ticket, they also see the non-member ticket. It’s highly unlikely someone will actively choose to buy the more expensive ticket, but for cleanness i wanted to hide the non-member ticket for members. Hope that simplifies? |
Ok, so do NOT set a minimum capability on the Non-Member ticket.
To keep that as is your going to need some custom development as the subscriber user will not see the ‘Non-member’ ticket. The snippet checks if the capability on a ticket is empty AND if your logged in, it then removes the ticket that doesn’t have a capability set from view. The Non-member ticket will not show to the subscriber as it doesn’t have a capability set on it.
That’s exactly what the snippet does 🙂 Because the ‘Non-member’ ticket doesn’t have a capability set on it and the user is logged in it removes that ticket from view. Logged out – http://take.ms/cAnb1 Logged in with the capability for the member ticket – http://take.ms/XbE7m If you were using the TOP snippet from here: https://gist.github.com/Pebblo/16a7dabb6a6d8f0f3d4370ccda06098b Then for that to happen you also need to setup a custom field on the event as shown in my above reply – http://take.ms/XvDao If you don’t want to have to do that you can use the bottom snippet from the above link. |
|
I’ve added another version of the snippet that will work for your subscriber set up: https://gist.github.com/Pebblo/16a7dabb6a6d8f0f3d4370ccda06098b#file-functions3-php Note this is check for an actual ‘subscriber’ role and not removing the tickets, if your using a different role you’ll need to edit the snippet to suit. |
|
|
Hi Tony Thanks for the above. I had tried all permutations but simply can’t get it to work at all. No matter which way i cut it, it’s either hides all or doesn’t hide any. You’ve shared a number of screen grabs. For the sake of putting a line under this (working or not), would you be able to screen grab the fields and values you’ve used to make the last snippet work. I’m sure i’m missing something, but i can’t see what on earth it is! Cheers, |
Are you logging in as a subscriber and as a ‘member’ to view the tickets? The above snippets skip everything if your user account has the ‘manage_options’ capability (meaning your an admin) and will just show all tickets IF your admin account has the caps set on the tickets (which it should really), if your admin account doesn’t have that cap you still can’t access it by default, the snippet is additional functionality, not replacement, to the default behaviour. My tickets – http://take.ms/VmEW5 Non-member ticket setup – http://take.ms/FF5d4 Member ticket setup – http://take.ms/6fkMg When viewing the event with a subscriber account – http://take.ms/A43NT When viewing the event as a user with ‘somecap’ on their account – http://take.ms/bLmWS When viewing the event with an admin account that has ALL caps assigned – http://take.ms/CFoam |
|
|
Hi Tony, I’ve been logging in using incognito as both ‘subscriber’ and ‘member’. The above is using function3? I’ll work through it again and screen grab what i’m seeing. Cheers |
|
Hi Tony, Screen grabs. 1. Capabilities of; 2. Tickets; 3. View as a logged out user https://snag.gy/c52xKG.jpg 4. View as a logged-in user (subscriber) https://snag.gy/uV0yJN.jpg 5. View as a logged-in user (member) https://snag.gy/kspWbN.jpg This doesn’t look like yours… |
|
Agggghhhhhhhh…….. sorry! I assumed (without checking your earlier comment correctly) and that is that I needed to change ‘subscriber’ to ‘member’. Which i don’t. It’s hiding from, not giving access to. I’m an idiot! Working correctly now : ) Thanks for your time and energy helping. |
You’re most welcome, I’m glad its now working for you 🙂 |
|
The support post ‘Multiple Ticket and Pricing Options – conditional logic/capability based filter’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.