Advertisement
Guest User

Untitled

a guest
Aug 4th, 2023
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.48 KB | None | 0 0
  1. <?php
  2.  
  3. add_filter( 'get_user_metadata', function( $meta_value, $user_id, $meta_key ) {
  4.     preg_match( '/^edit_(.*)_per_page$/', $meta_key, $matches );
  5.     if ( is_array( $matches ) && ! empty( $matches[1] ) ) {
  6.         global $wpdb;
  7.         $type = $matches[1];
  8.         $per_page = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM $wpdb->usermeta WHERE meta_key = '$type' AND user_id = %d", $user_id ) );
  9.         if ( ! $per_page ) {
  10.             $meta_value = 100;
  11.         }
  12.     }
  13.     return $meta_value;
  14. }, 10, 3 );
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement