Force login on one ticket

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 6 years, 5 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #28915

    Hi,

    On one event, I have 2 tickets: one for members and one for non-members. All members are users in the database. Is there a way that I can force someone to login in order to be able to buy the member ticket? This way, I would avoid having non-members trying to buy tickets at the member price.

    Thanks,

    Luc

    Luc Gagnon
    #28918

    You can do something like the following:

    add_filter( 'eventorganiser_get_event_tickets', function( $tickets, $event_id, $occurrence_ids ) {
    
        // Logged-in users can access all tickets
        if ( is_user_logged_in() ) {
            return $tickets;
        }
    
        // Go through each ticket and remove 
        // any 'members only ones'
        foreach( $tickets as $ticket_id => $ticket ) {
            if ( $ticket['name'] == 'Members ticket' ) {
                unset( $tickets[$ticket_id] );
            }
        }
    
        return $tickets;
    
    }, 10, 3 );
    

    You’ll have to edit the above to supply the logic for determining whether a ticket is members only or not. In this example, it treats any ticket with the name ‘Members ticket’ as a members-only ticket.

    Members tickets will not be visible to logged-out users.

    The above also assumes if the user is logged-in then they are member. You can add any additional checks if that might not necessarily be the case (e.g. membership has not lapsed).

    Stephen Harris
Viewing 2 posts - 1 through 2 (of 2 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.