Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * Filter player setup to remove ads for custom roles.
- *
- * @param array $setup
- * @param int|string $source
- *
- * @return array $setup filtered $setup
- *
- */
- add_filter( 'streamtube/player/file/setup', function( $setup, $source ){
- // Holds an array of custom roles
- $custom_roles = array( 'role1', 'role2', 'role3' );
- // Get current logged in user data
- $user_data = wp_get_current_user();
- if( array_intersect( $user_data->roles, $custom_roles ) ){
- // If the logged-in user's role matches, remove the advertising
- if( array_key_exists( 'advertising', $setup ) ){
- unset( $setup['advertising'] );
- }
- }
- return $setup;
- }, 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement