nanodesigns / nanosupport

Create a fully featured Support Center in your WordPress setup without any third party dependency, completely FREE. Get a built-in Knowledgebase too. The plugin is available on WordPress.org repository:
https://wordpress.org/plugins/nanosupport/
GNU General Public License v2.0
50 stars 13 forks source link

Accessing Ticket Database #91

Closed AndrewMc354 closed 4 years ago

AndrewMc354 commented 4 years ago

Hi I am using nanosupport with knowledge base and am trying to produce graphs based off tickets that have been created and I was wondering where the tickets are stored? Are they in a phpmyadmin database? If so what name is it please as i cannot find it.

Kind Regards

mayeenulislam commented 4 years ago

There's already a 📈 graph exists in the admin panel dashboard showing total tickets and the breakdown with respective counts.

But if you still need to make a query of your own, the data is stored like the WordPress in the MySQL database in tables: posts, post_meta and other tables. You will need to have some understanding on how WordPress works with posts and post_meta.

BTW, here's a simple query (using WordPress' WP_Query) to fetch tickets' basic information:

<?php
$tickets = new WP_Query(
    array(
        'post_type'      => 'nanosupport',
        'post_status'    => array( 'publish', 'private', 'pending' ),
        'posts_per_page' => -1,
    )
);

if ($tickets->have_posts()) :
    while ($tickets->have_posts()) :
        $tickets->the_post();
        the_title(); // Ticket title

        $ticket_status   = get_post_meta(get_the_ID(), '_ns_ticket_status', true);
        $ticket_priority = get_post_meta(get_the_ID(), '_ns_ticket_priority', true);

        echo '<br>';
        printf( 'Ticket Status: %s', $ticket_status );
        echo '<br>';
        printf( 'Ticket Priority: %s', $ticket_priority );
    endwhile;
endif;
wp_reset_postdata();
?>