Advertisement
arie_cristianD

filter pay author stats

Nov 14th, 2023 (edited)
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.44 KB | None | 0 0
  1. /* filter pay author stats */
  2.  
  3. add_filter( 'jpwt_formatted_stats', 'only_author' );
  4.  
  5. function only_author( $formatted_stats ) {
  6.     foreach ( $formatted_stats['stats'] as $key => $stats ) {
  7.  
  8.         $user = get_userdata( $stats['author_id'] );
  9.         if ( ! in_array( 'author', $user->roles ) ) {
  10.             unset( $formatted_stats['stats'][ $key ] );
  11.         }
  12.     }
  13.     $formatted_stats['stats'] = array_values( $formatted_stats['stats'] );
  14.     return $formatted_stats;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement