Support

Home Forums Event Espresso Premium Multiple Ticket and Pricing Options – capability based filter (follow up)

Multiple Ticket and Pricing Options – capability based filter (follow up)

Posted: June 8, 2017 at 8:39 pm

Viewing 9 reply threads


jbbruning

June 8, 2017 at 8:39 pm

Hi there,

I had a quick question.

Tony kindly (and patiently) helped me with visibility of tickets for member/non-member based on capability using this function

functions3.php https://gist.github.com/Pebblo/16a7dabb6a6d8f0f3d4370ccda06098b#file-functions3-php

However i’ve discovered that not on every occasion will there be a non-member price AND member price scenario. In some cases there will be “accessible to all” tickets.

The code i’m using (from the snippet) is set to assume a member and non-member ticket. In other words, if there are ticket(s) that don’t have the capability set on the ticket it’s hidden. That’s cool for all situations, except a ticket-for-all scenario.

Is there a way to change the code to allow and all users scenario?

Many thanks


Tony

  • Support Staff

June 9, 2017 at 2:33 am

Sounds like with the ‘ticket-for-all’ scenario you need to disable the above snippet completely so that whatever tickets are set on the event will show up.

If you then don’t have access to the ticket based on capabilities it would show the default message but if no cap was set it would display the ticket, is that what you are looking for?


jbbruning

June 9, 2017 at 4:37 am

Hi Tony,

In 90% of cases the scenario of member/non-member tickets and visibility (and hidden) tickets would as the snippet intends.

On the odd occasions where there is just a single ticket for all, it would be great to allow for that scenario. Not sure if it’s possible with a code extension?

At the moment we are having to create 2 tickets at the same price, because a member would see no tickets if there is no capability put on the ticket.

Does that make sense?

Matt


Tony

  • Support Staff

June 9, 2017 at 7:20 am

I’d do that with an event meta value like so:

$event = $ticket->get_related_event();

$skip_hide_tickets = $event->get_extra_meta( 'skip_hide_tickets', true );

if( $skip_hide_tickets ) {
 return $return_value;
}

Add that above Line 9 of the gist you are using.

Then on the events that you don’t want the code from the gist to run on add a meta value of ‘skip_hide_tickets’ – http://take.ms/hgdJe

(You can use ACF or similar to make a checkbox if preferred.


jbbruning

June 9, 2017 at 10:15 am

Thanks Tony,

Unfortunately it’s still not showing any ticket options as a member, with the above code and adding a custom meta to the event.

I’ve added the code, added the custom meta, removed the capability requirement.

That’s correct, right?

Cheers


Tony

  • Support Staff

June 9, 2017 at 10:25 am

I have no idea without seeing the code ๐Ÿ™‚

Can you create a gist of the code you have, and take a screenshot of the event meta you added to the event?


jbbruning

June 9, 2017 at 7:36 pm

Hi Tony,

This is the code i’m using


// hide no accessible tickets
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();

	$skip_hide_tickets = $event->get_extra_meta( 'skip_hide_tickets', true );

	if( $skip_hide_tickets ) {
 	return $return_value;
	}
	
    $cap_required = $ticket->get_extra_meta( 'ee_ticket_cap_required', true );
  
    if( empty( $cap_required ) && ( is_user_logged_in() && ! current_user_can( 'manage_options') ) ) {
        if( current_user_can( 'subscriber' ) ){
            return $return_value;
        } 		
		
		else {
            return '';
        }
    }
    return $return_value;
}
add_filter( 'FHEE__ticket_selector_chart_template__do_ticket_inside_row', 'tw_ee_hide_no_cap_tickets_from_logged_in_users', 20, 9);

The custom field is as you have it on your screen grab. Nothing added to the capabilities required field on the ticket itself.

Thanks for taking a look.


Tony

  • Support Staff

June 12, 2017 at 5:09 am

Yeah, I see, I made a silly mistake.

This line:

$skip_hide_tickets = $event->get_extra_meta( 'skip_hide_tickets', true );

needs to be:

$skip_hide_tickets = $event->get_post_meta( 'skip_hide_tickets', true );

It should work then.


jbbruning

June 13, 2017 at 3:49 am

Thanks Tony. Works now : )

Appreciate your time again.


Tony

  • Support Staff

June 13, 2017 at 3:56 am

You’re most welcome ๐Ÿ™‚

Viewing 9 reply threads

The support post ‘Multiple Ticket and Pricing Options – capability based filter (follow up)’ 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