Support » Plugin: Audit Trail » Audit trail screens only showing latest events

  • I installed Audit Trail on an extranet site I developed for a client so that they could monitor who was using it and paid commercial donation of $42. The Audit Trail screen currently shows 794 items with 32 screens of 25 events. However if you scroll from the 1st screen to the second screen the event at the top of the screen is removed and it shows the next 25 events – so repeating 24 events that were on the 1st screen. The next screen removes the top event again, thus repeating 24 events from screen 2 and so on, so you are unable to see all 794 events shown. However if you download a csv file it does show all 794 events. Please can you help?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello, is there any one there? I’m looking into why the paging isn’t working. It appears this plug-in is no longer maintained.

    same issue as reported previously 4 months ago 🙁


    Please modify the audit-trails/models/pager.php file in the function prepare_items() around line 110:

    $rows = $wpdb->get_results( $wpdb->prepare("SELECT {$wpdb->prefix}audit_trail.*,{$wpdb->users}.user_nicename AS username FROM {$wpdb->prefix}audit_trail LEFT JOIN {$wpdb->users} ON {$wpdb->users}.ID={$wpdb->prefix}audit_trail.user_id ORDER BY ".$orderby.' '.$order." LIMIT %d,%d", (($this->get_pagenum() - 1) * $per_page), $per_page));

    The issues is the the use of the MySQL LIMIT where as the first parameter is the page number and the second is how many to display per page. The starting parameter should be the row count to start with so we need to determine that number. In my case, I just decided to subtract 1 from the current page and use that as my starting row. After that, beginning with page 2, I want to show rows starting at 25, for 25 count. For page 3, it would be row 50 for 25.

    Page 1 = ... LIMIT 0,25
    Page 2 = ... LIMIT 25,25
    Page 3 = ... LIMIT 50,25
    Page 4 = ... LIMIT 75,25
    Page 5 = ... LIMIT 100,25

    This resolves the pagination issue.

    Hi Chuckfloyd
    That’s great, thank you! I have added the code and it works fine.

    An alternative to fix, though similar in operation.

    $offset = ( $current_page - 1 ) * $per_page;
    $rows   = $wpdb->get_results( $wpdb->prepare( "SELECT {$wpdb->prefix}audit_trail.*,{$wpdb->users}.user_nicename AS username FROM {$wpdb->prefix}audit_trail LEFT JOIN {$wpdb->users} ON {$wpdb->users}.ID={$wpdb->prefix}audit_trail.user_id ORDER BY ".$orderby.' '.$order." LIMIT %d,%d", $offset, $per_page ) );
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Audit trail screens only showing latest events’ is closed to new replies.