bp_core_avatar_reset_query

Reset the week parameter of the WordPress main query if needed.

Description

bp_core_avatar_reset_query( (null) $posts_query = null ); 

When cropping an avatar, a $_POST['w'] var is sent, setting the week parameter of the WordPress main query to this posted var. To avoid notices, we need to make sure this week query var is reset to 0.

Parameters (1)

0. $posts_query — Optional. (null) => null
The main query object.

Usage

  1. if ( !function_exists( 'bp_core_avatar_reset_query' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-avatars.php'; 
  3.  
  4. // The main query object. 
  5. $posts_query = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_core_avatar_reset_query($posts_query); 
  9.  

Defined (1)

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

/bp-core/bp-core-avatars.php  
  1. function bp_core_avatar_reset_query( $posts_query = null ) { 
  2. $reset_w = false; 
  3.  
  4. // Group's avatar edit screen. 
  5. $reset_w = bp_is_group_admin_screen( 'group-avatar' ); 
  6.  
  7. // Group's avatar create screen. 
  8. } elseif ( bp_is_group_create() ) { 
  9. /** 
  10. * as it's not set yet 
  11. */ 
  12. $reset_w = 'group-avatar' === bp_action_variable( 1 ); 
  13.  
  14. // User's change avatar screen. 
  15. } else { 
  16. $reset_w = bp_is_user_change_avatar(); 
  17.  
  18. // A user or a group is cropping an avatar. 
  19. if ( true === $reset_w && isset( $_POST['avatar-crop-submit'] ) ) { 
  20. $posts_query->set( 'w', 0 );