Ticket search in support system not finding ticket.

Ignacio ol buddy, I have another question for you about the support system :slight_smile:
Using the ticket search box it finds my tickets most of the time but occasionally does not.

Normally I search for the users name or username and it works fine.

I just tested and have a user "acrane" and the url of the sub domain is also "acrane" but their tickets do not show up under a search even when searching by their name.

One of those would usually work, any ideas what would prevent some users from showing in the search or too hard to tell?

You may still have my login info and if so you can try searching for that user and see that they have a few recent tickets if you want to try a quick test.

Any advice appreciated.

thanks!!!

  • Vinod Dalvi

    Hi George,

    I hope you are well today and thanks for posting on the forum.

    I logged in to your site using support staff access and could confirm the issue for the user "acrane".

    This may be due to the user name and site name is same so could you please test it creating another user having different user name than the site?

    I have tested it on my test site using latest version of Support System plugin and found the ticket search only works for topic names and not user names.

    Searching by Subject of the support ticket is working fine on my test site and also on your site which i have confirmed.

    I have notified the plugin developer to get his valuable reply here regarding this.

    He will reply here ASAP.

    Thanks,
    Vinod Dalvi

  • George

    This may be due to the user name and site name is same so could you please test it creating another user having different user name than the site?

    My this is multisite & my signup form creates all sub-sites with a url that is the same as the username.

    I can search for other tickets using the username fine.

    I don't really need to search by topic name because users all pick the topic but it is nice to be able to see all the tickets for a particular user if possible. Which it does do for most of my users I have tested.
    thanks!

  • Ignacio

    Hi @George.

    The way Support System is coded right now could make that search slow in some sites. We may need an advanced search for that so I'll note this idea for future releases.

    However I've found a solution in your case.

    1. You'll need to change the line 149 in file inc/helpers/ticket.php for this one:

    $where = apply_filters( 'support_system_get_tickets_where', $where, $count, $args );

    Don't worry, changes will remain in 2.1.9 version.

    2. Now you need to add the following code in an external plugin (or MU Plugin, like you did with attachments extensions):

    add_filter( 'support_system_get_tickets_where', 'george_filter_search_by_username', 10, 3 );
    function george_filter_search_by_username( $where, $count, $args ) {
    	global $wpdb;
    
    	if ( ! $args['s'] )
    		return $where;
    
    	$user = get_user_by( 'login', $args['s'] );
    	if ( ! $user )
    		return $where;
    
    	$where .= $wpdb->prepare( " OR t.user_id = %d OR t.admin_id = %d", $user->ID, $user->ID );
    
    	return $where;
    }

    Now you can search by user login (not by user ID or nicename). You need to insert the exact user login in the search box or it won't work.

    Regards.
    Ignacio.

  • George

    Hey Ignacio, I got these errors:

    Cannot send session cache limiter - headers already sent (output started at /home/evantage/public_html/wp-content/mu-plugins/ticket-search-by-user.php:22) in /home/evantage/public_html/wp-content/plugins/wpmu-dev-facebook/lib/external/facebook.php on line 60
    
    Warning: Missing argument 3 for george_filter_search_by_username() in /home/evantage/public_html/wp-content/mu-plugins/ticket-search-by-user.php on line 7

    Not really a big deal and I can wait for the next update if that is in the works :slight_smile:

    thanks!

  • Vinod Dalvi

    Hi @George,

    To resolve the shared warning message could you please try using the following modified code replacing previously shared code.

    add_filter( 'support_system_get_tickets_where', 'george_filter_search_by_username', 10, 3 );
    function george_filter_search_by_username( $where, $count, $args = array() ) {
    	global $wpdb;
    
    	if ( ! $args['s'] )
    		return $where;
    
    	$user = get_user_by( 'login', $args['s'] );
    	if ( ! $user )
    		return $where;
    
    	$where .= $wpdb->prepare( " OR t.user_id = %d OR t.admin_id = %d", $user->ID, $user->ID );
    
    	return $where;
    }

    Best Regards,
    Vinod Dalvi

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.