Advertisement
phpface

Untitled

Feb 25th, 2023
1,028
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.67 KB | None | 0 0
  1. /**
  2.  *
  3.  * Filter player setup to remove ads for custom roles.
  4.  *
  5.  * @param array $setup
  6.  * @param int|string $source
  7.  *
  8.  * @return array $setup filtered $setup
  9.  *
  10.  */
  11. add_filter( 'streamtube/player/file/setup', function( $setup, $source ){
  12.  
  13.     // Holds an array of custom roles
  14.     $custom_roles   = array( 'role1', 'role2', 'role3' );
  15.  
  16.     // Get current logged in user data
  17.     $user_data      = wp_get_current_user();
  18.  
  19.     if( array_intersect( $user_data->roles, $custom_roles ) ){
  20.         // If the logged-in user's role matches, remove the advertising
  21.         if( array_key_exists( 'advertising', $setup ) ){
  22.             unset( $setup['advertising'] );
  23.         }
  24.     }
  25.  
  26.     return $setup;
  27.  
  28. }, 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement