Support

Home Forums Event Espresso Premium Replace ticket information for a specific ticket after purchased

Replace ticket information for a specific ticket after purchased

Posted: September 21, 2018 at 3:52 pm

Viewing 12 reply threads


sogtalks@gmail.com

September 21, 2018 at 3:52 pm

I would like to replace the ticket information for a specific ticket with text once a user has purchased (x) tickets. The next time they log in they would still see the replacement text.

So I have to check to see if they have the ticket(s), then provide else text.

I can’t use capabilities as they will be buying tickets in the future.

Can you point me in the right direction. Thank you.


Tony

  • Support Staff

September 24, 2018 at 4:22 am

Hi there,

Whilst we don’t support customizations, we can help point you in the right direction.

When you say the ticket information, where do you want to change this?

It sounds like you may be trying to prevent registrations on a specific ticket after X amount ticket registrations, is that right?


sogtalks@gmail.com

September 24, 2018 at 10:26 am

It sounds like you may be trying to prevent registrations on a specific ticket after X amount ticket registrations, is that right?

Correct. See https://ibb.co/dmcT1p . I have already hidden the member ticket based on membership level (PMP Pro) I’m thinking I should be able to do the same if I can connect ticket to user?


Josh

  • Support Staff

September 24, 2018 at 11:55 am

Hi,

I can point you in the direction of using a one-time capability for that ticket. Here’s a link to instructions on how to set this up:

https://gist.github.com/joshfeck/51c2ef122616b48cc4846b1f44384859


sogtalks@gmail.com

September 24, 2018 at 12:35 pm

Ok,

That makes sense now that I think of it. I had thought of each ticket as being the same (in general terms they are the same kind) when in fact they are completely different; different dates.

So now I have to add a unique code for each unique event ticket, add it the permissions for each role, add it to each ticket and then when the ticket is registered it removes that capability. That works for one ticket type where I want to remove the ticket after a single registration/purchase but I want the user to also be able to purchase up to 10 guest tickets which can be purchase one at a time; I cannot have the capability removed for that ticket (until (10) sold for example.

Also how do I replace the ticket information with text when the capability is removed.

Thank you for your help and patience.


Josh

  • Support Staff

September 24, 2018 at 12:59 pm

Hi,

The specification to keep track of up to 10 guest tickets makes for a very tricky problem to solve. Is there a PHP developer on your team that can put together a way to track those? One way that could be done is track that via the user_meta. That would need to be custom coded.

The ticket information will automatically show text informing them the ticket isn’t available. That text can be customized via the
FHEE__EED_WP_Users_Ticket_Selector__maybe_restrict_ticket_option_by_cap__no_access_msg
Here’s a link to some example code that shows how to customize that message:
https://gist.github.com/Pebblo/783dc4f9f43b9780d860112817edfd6d


sogtalks@gmail.com

September 24, 2018 at 1:16 pm

I can resolve the guest tickets.

To be clear on removing the one-time capability; I have to run the function for each individual ticket?

Thank you.


Josh

  • Support Staff

September 24, 2018 at 1:21 pm

I’m not sure I understand your question. Which function? Do you mean the
my_remove_one_time_invitation_from_user function from the example? That actually runs on a hook when the registration is processed.


sogtalks@gmail.com

September 24, 2018 at 5:53 pm

Yes. But if I have 4 unique tickets, each with it’s own “capability” code, I will have to account for each one in the function?

function my_remove_one_time_invitation_from_user() {
  if (current_user_can( 'has_unique_invitation_code' )){
    $user = new WP_User( get_current_user_id() );
    $user->remove_cap( 'has_unique_invitation_code' );
  }


sogtalks@gmail.com

September 25, 2018 at 8:37 am

To clarify I cannot use a single capability code as each ticket is offered at different events. The members have access to multiple events.


Tony

  • Support Staff

September 25, 2018 at 11:12 am

You can use something like this function:

https://gist.github.com/Pebblo/25cab2c24fe28b0c65285b15f0e25104#file-example-multiple-caps-php

What that does is check if the ticket has a capability that contains the text ‘has_unique_invitation_code’ set on it, if it does, it removes that capability from the user.

So if you had each ticket setup like so:

Ticket 1 has has_unique_invitation_code_ticket_1
Ticket 2 has has_unique_invitation_code_ticket_2

When the user registers onto Ticket 1 has_unique_invitation_code_ticket_1 will be removed, when they register onto Ticket 2, has_unique_invitation_code_ticket_2 will be removed.

If they register onto both tickets in a single registration, both capabilities are removed.

Is that what you are looking for?

Note that you still need to add those individual capabilities to the users and if you want to use a different text string to search for on your caps, you can change the string HERE


sogtalks@gmail.com

September 25, 2018 at 12:56 pm

Yes that’s exactly what I meant. I’m going to implement that:

  • add unique capability code for each ticket (rsvp_oct022018, rsvp_nov022018 for example)
  • add each of those capabilities to the role that applies (Member)
  • build remove capabilities plugin as suggested
  • build plugin to replace ticket info in ticket table with text indicating they have already registered

My only concern is if they cancel their ticket registration, and I know it’s going to happen. I will have to manually add that capability back to that user, or register them manually.

Not clear on what you mean:

if you want to use a different text string to search for on your caps, you can change the string HERE

Thank you, a great help.


Tony

  • Support Staff

September 25, 2018 at 2:05 pm

Not clear on what you mean:

Well, the capability you are looking for is, for example, rsvp_oct022018

My code wont work for you as it looks for a capability with the string has_unique_invitation_code in it.

So you’d need to change line 32

From && strpos($cap_required, 'has_unique_invitation_code' ) !== false

To something like:

&& strpos($cap_required, 'rsvp_' ) !== false

rsvp_oct022018 contains rsvp_ so strpos() will not return false, meaning that code will then run.

My only concern is if they cancel their ticket registration, and I know it’s going to happen. I will have to manually add that capability back to that user, or register them manually.

That’s correct, we don’t have any example code to do that for you currently.

Viewing 12 reply threads

The support post ‘Replace ticket information for a specific ticket after purchased’ 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.

Event Espresso