PHP: Check if user has updated support ticket.

Hello

What would be the php code to use to check if a user has any updated tickets that are for example “Waiting on User to reply”? Is there any built in code for the plugin to check this?

Many thanks.

  • Rupok
    • Ex Staff

    Hi Elliot Sowersby, hope you had a wonderful day.

    I’m afraid, this is not possible with currently available options in Support System plugin. But if you wanna custom develop this function, our plugin developer can give you best idea regarding how you can do this. So I’m pinging our developer for his valuable feedback on this. Please keep in mind, our developers work round the clock and they have to deal with lots of critical issues and other things. So it may take a little while for them to check this and provide a feedback.

    I’ll update you as soon as I get something from our developer.

    Have a nice day. Cheers!

    Rupok

  • Ignacio
    • HummingBird

    Hi Elliot Sowersby

    Here’s a piece of code to start with (I haven’t tested myself but should work). Imagine you want to get all tickets assigned to a user with ID = 5 and status “Waiting on user to reply”:

    <?php

    $tickets = incsub_support_get_tickets(array(
    'status' => 2,
    'per_page' => -1
    ));
    wp_list_filter( $tickets, array( 'admin_id' => 5 ) );

    Unfortunately, admin_id cannot be used on incsub_support_get_tickets for the moment but you can filter the tickets after getting all of them by status.

    See incsub-support/inc/helpers/ticket.php for more functions related to tickets.

    Regrads.

    ignacio.

  • Elliot Sowersby
    • The Incredible Code Injector

    Awesome, thanks Ignacio. This worked like a charm with a few small changes.

    Here it is for anyone else that needs to do this:

    global $current_user;
    $current_user = wp_get_current_user();

    $tickets = incsub_support_get_tickets(array(
    'status' => 2,
    'per_page' => -1
    ));
    wp_list_filter( $tickets, array( 'admin_id' => $current_user->ID ) );

    /* Total active tickets */
    $ticketnum = sizeof($tickets) - 1;

    if ($tickets) {
    /* INSERT CODE TO DISPLAY IF NEW TICKETS */
    }

  • Elliot Sowersby
    • The Incredible Code Injector

    Not sure if this is the best way to fix it, but a temporary fix for me was the following:

    Add to line 89 of /wp-content/plugins/incsub-support/inc/helpers/ticket.php

    elseif ( '2' == $status )
    $where[] = 't.ticket_status = 2';

    Only problem is on plugin updates this will be erased.