• Resolved Greg McEwan-Marriott

    (@gregthebuzz)


    Anybody have an idea how i could do the following ;

    User A buys ticket
    User A changes attendee email and name
    above two points are available as is in Event Tickets but for security reasons I am trying to the following

    User B receives pdf ticket via mail with a NEW ticket security code and QRcode
    User B is then registered as the purchaser for the related woocommerce order (this prevents the original purchaser from reselling his ticket again)

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Greg McEwan-Marriott

    (@gregthebuzz)

    a better solution?

    User A buys ticket no 500
    User A sells ticket no 500 to another person by

    1. Transfer ticket to Person B – supplies name, tel, email – the system sends the sec code on old ticket to Person B
    2. Message gets sent to Person B – to register account – becomes User B
    3. User B gets list of pending transfer tickets – from his account
    4. User B pays decibel for ticket by entering sec code and completes payment
    5. On payment funds get transferred into User A wallet
    6. System replaces original ticket with User B details and issues new ticket to User B
    7. User A can then request refund if required

    Plugin Support tristan083

    (@tristan083)

    Hi @gregthebuzz ,

    Thank you for reaching out.

    It seems you are raising a concern on a feature that ships with one of our premium plugins, Event Tickets Plus. For us to assist you better, please open a Support Ticket on our Help Desk. Also, this is for us to follow WordPress Forum Guidelines regarding premium users.??

    One of my colleagues will be with you shortly. We look forward to helping you out with this one. 

    Hang in there.

    Plugin Support Darian

    (@d0153)

    Hi there,

    It appears that we haven’t heard back from you in a while, so I’ll assume that the matter has been resolved. If you need any more help, feel free to start a new thread and we’ll be happy to assist you.

    Thread Starter Greg McEwan-Marriott

    (@gregthebuzz)

     was asked to improve the chances of ticket pass fraud from people buying tickets with Event Tickets Plus (The Events Calendar WordPress plugin). When someone buys say 2 passes to an event they get issued two PDF passes emailed to the the two attendees they added to the event… The purchaser can then go update the Attendee information afterwards e.g. Ticket Holder Name and Email address.

    The worry was that

    1. The new Attendee may not be a woocommerce customer/WP user and
    2. what stops the purchaser from “re-selling” fake passes by continually going to update his two ticket attendees, each getting sent a PDF ticket and when they get to the event the first to check in would get in BUT the rest would not be able to be scanned it via the QRcode scanner and security code attached in the ticket pass…

    OK, so I decided to use css to hide the built in Update Attendee Information in the plugin and then using ACF built a form that contains 3 fields

    1. The Current Ticket ID
    2. a new ticket_holder (name) field
    3. a new ticket_email_to (email) field

    The form runs a hook called transfer_ticket on update that runs the following function (excuse my bad coding but it works)

        add_action('acf/save_post', 'transfer_ticket'); 

    function transfer_ticket( $post_id ) {

    global $wpdb;
    global $post;
    global $user;

    $pid = intval($_GET["tid"]);
    $ticket_holder = get_post_meta($post_id, 'ticket_holder',true);
    $ticket_email_to = get_post_meta($post_id, 'ticket_email_to',true);
    $_unique_id = get_post_meta($post_id, '_unique_id',true);

    $_tribe_wooticket_event = get_post_meta($post_id, '_tribe_wooticket_event',true);
    $_tribe_wooticket_order = get_post_meta($post_id, '_tribe_wooticket_order',true);
    $_tribe_wooticket_product = get_post_meta($post_id, '_tribe_wooticket_product',true);

    $lastDelimiterPos = strrpos($_unique_id, '-');
    $lastpart = substr($_unique_id, $lastDelimiterPos + 1);

    //update_post_meta($post_id, '_tribe_tickets_full_name', $ticket_holder);
    //update_post_meta($post_id, '_tribe_tickets_email', $ticket_email_to);

    // First, make sure the email address is set
    if ( isset( $ticket_email_to ) && ! empty( $ticket_email_to ) ) {

    // Next, sanitize the data
    $email_addr = trim( strip_tags( stripslashes( $ticket_email_to ) ) );
    $exists = email_exists($email_addr);


    if ( !$exists) {

    $xname = trim($ticket_holder);
    $last_name = (strpos($xname, ' ') === false) ? '' : preg_replace('#.*\s([\w-]*)$#', '$1', $xname);
    $first_name = trim( preg_replace('#'.preg_quote($last_name,'#').'#', '', $xname ) );
    $args = array('first_name' => $first_name, 'last_name' => $last_name);

    $newid ='';
    $length = 6 ;
    $batch = array_merge( range( '0', '9' ), range( 'A', 'Z' ) );

    shuffle( $batch );
    $id = '';
    $keys = array_rand( $batch, $length );

    foreach ( $keys as $index ) {

    $newid .= $batch[ $index ];

    }

    $n_unique_id = str_replace($lastpart,$newid , $_unique_id);
    update_post_meta($post_id, 'last_name', $last_name); // for testing
    update_post_meta($post_id, 'first_name', $first_name); // for testing
    update_post_meta($post_id, 'newid', $newid); // for testing
    update_post_meta($post_id, 'lastpart', $n_unique_id); // for testing


    $username = sanitize_title( $ticket_holder );
    $user_login = wp_slash( $username );
    $user_email = wp_slash( $email_addr );
    $user_pass = wp_generate_password( 6, false );;
    $userdata = compact( 'user_login', 'user_email', 'user_pass' );

    // Create the new user
    $new_user_id = wp_create_user( $user_login, $user_pass, $user_email );


    // Get current user object
    $user = get_user_by( 'id', $new_user_id );

    // Remove role
    $user->remove_role( 'subscriber' );

    // Add role
    $user->add_role( 'customer' );

    wp_update_user( array( 'ID' => $user->ID, 'display_name' => sanitize_text_field($xname) ) );
    update_user_meta($user->ID, 'first_name', $first_name);
    update_user_meta($user->ID, 'last_name', $last_name);

    $nsecurity_code = substr( md5( wp_rand() . '_' . $user->ID ), 0, 10 );

    update_post_meta($post_id, '_tribe_wooticket_security_code', $nsecurity_code);
    update_post_meta($post_id, '_unique_id', $n_unique_id);
    update_post_meta($post_id, '_tribe_tickets_email', $user_email);
    update_post_meta($post_id, '_tribe_tickets_full_name', $xname);
    update_post_meta($post_id, '_tribe_tickets_attendee_user_id', $new_user_id);
    echo "<script type='text/javascript'>alert('Ticket has been transferred !!!');</script>";

    } else {
    //echo '</br> User exists';
    }

    header("Location: https://somewebsite.com/my-dashboard/bookings/");
    die();
    }



    }
    //

    In essence and I have tested this the following happens

    1. It creates a new WP user with a customer role ‘Customer’ if user email does not exists in WP
    2. It updates the existing ticket meta with the new users email and names and the ticket _tribe_tickets_attendee_user_id with the new WP user
    3. It recreates the ticket’s security code (used in the QR)
    4. It recreates the ticket’s _unique_id that is essential to check in successfully

    So the new user can now log in and see his ticket and add it to his Google or iphone Wallet or download his pdf ticket. I have tested with the mobile app and the new issued ticket checks in 100% fine using the QR scanner

    NOW THE ISSUE IS

    I an trying to get the function above to somehow hook into The Events Calendar Ticket plugin to automatically send the new user his PDF ticket !!! AND i cannot seem to figure it out. I have the ticket ID and the Event ID and the user ID and details, but how do i resend the ticket?

    Is there a hook I can call?

    I looked through the code in the plugin and only thing that closely resembles a hook or function i can call is situated in wp-content/plugins/event-tickets-plus/src/Tickets_Plus/Commerce/Attendee_Registration/Hooks.php

    lines 171-182

    public function update_attendee_meta_my_tickets_page( $attendee_id, $data_to_save, $data, $order_id, $ticket_id, $post_id, $provider ) {
    $args = [
    'fields' => $data,
    ];

    $ticket = tribe( Commerce\Ticket::class )->get_ticket( $ticket_id );

    // Always inject IAC after Fields.
    $args = $this->container->make( Attendee::class )->inject_individual_collection_args( $args, $ticket );

    $attendee = tec_tc_attendees()->by( 'id', $attendee_id )->set_args( $args )->save();
    }`

    Anybody able to help me find a way to resend the ticket as a PDF?

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.