Advertisement
phpface

Maximum allowed number of uploads

Aug 14th, 2023 (edited)
976
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.95 KB | None | 0 0
  1. function streamtube_child_check_limit_uploads( $errors ){
  2.  
  3.     $max_allowed                = 10;
  4.  
  5.     $current_user_total_posts   = count_user_posts( get_current_user_id(), 'video' );
  6.  
  7.     // Check roles ... etc
  8.    
  9.     // This limitation should not apply to administrator and editor, maybe.
  10.    
  11.     if( ! current_user_can( 'administrator' ) ){
  12.         if( $current_user_total_posts > $max_allowed ){
  13.             $errors->add(
  14.                 'not_allowed',
  15.                 esc_html__( 'You have reached the maximum allowed number of uploads.', 'streamtube-child' )
  16.             );
  17.         }        
  18.     }
  19.  
  20.     return $errors;
  21.  
  22. }
  23. add_filter( 'streamtube/core/upload/video/errors', 'streamtube_child_check_limit_uploads', 100, 1 );
  24. add_filter( 'streamtube/core/upload_chunks/video/errors', 'streamtube_child_check_limit_uploads', 100, 1 );
  25. add_filter( 'streamtube/core/post/import_embed/errors', 'streamtube_child_check_limit_uploads', 100, 1 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement