can_user_create_album_in_group

Checking if user can create an album in BuddyPress group.

Description

can_user_create_album_in_group( (constant) $group_id = false, (bool) $user_id = false ); 

Parameters (2)

0. $group_id — Optional. (constant) => false
The group id.
1. $user_id — Optional. (bool) => false
The user id.

Usage

  1. if ( !function_exists( 'can_user_create_album_in_group' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'rtmedia-for-wordpress-buddypress-and-bbpress/app/main/controllers/template/rtmedia-functions.php'; 
  3.  
  4. // The group id. 
  5. $group_id = false; 
  6.  
  7. // The user id. 
  8. $user_id = false; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = can_user_create_album_in_group($group_id, $user_id); 
  12.  

Defined (1)

The function is defined in the following location(s).

/app/main/controllers/template/rtmedia-functions.php  
  1. function can_user_create_album_in_group( $group_id = false, $user_id = false ) { 
  2.  
  3. if ( false == $group_id ) { 
  4. $group = groups_get_current_group(); 
  5. $group_id = $group->id; 
  6.  
  7. $upload_level = groups_get_groupmeta( $group_id, 'rt_media_group_control_level' ); 
  8.  
  9. if ( empty( $upload_level ) ) { 
  10. $upload_level = groups_get_groupmeta( $group_id, 'bp_media_group_control_level' ); 
  11.  
  12. if ( empty( $upload_level ) ) { 
  13. $upload_level = 'all'; 
  14.  
  15. $user_id = get_current_user_id(); 
  16. $display_flag = false; 
  17.  
  18. if ( groups_is_user_member( $user_id, $group_id ) ) { 
  19. if ( 'admin' === $upload_level ) { 
  20. if ( groups_is_user_admin( $user_id, $group_id ) > 0 ) { 
  21. $display_flag = true; 
  22. } else { 
  23. if ( 'moderators' === $upload_level ) { 
  24. if ( groups_is_user_mod( $user_id, $group_id ) || groups_is_user_admin( $user_id, $group_id ) ) { 
  25. $display_flag = true; 
  26. } else { 
  27. $display_flag = true; 
  28.  
  29. $display_flag = apply_filters( 'can_user_create_album_in_group', $display_flag ); 
  30.  
  31. return $display_flag; 
  32.