bp_core_avatar_reset_query( WP_Query|null $posts_query = null )

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

Description

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

$posts_query

(WP_Query|null) (Optional) The main query object.

Default value: null

Source

File: bp-core/bp-core-avatars.php

function bp_core_avatar_reset_query( $posts_query = null ) {
	$reset_w = false;

	// Group's avatar edit screen.
	if ( bp_is_group_admin_page() ) {
		$reset_w = bp_is_group_admin_screen( 'group-avatar' );

	// Group's avatar create screen.
	} elseif ( bp_is_group_create() ) {
		/**
		 * We can't use bp_get_groups_current_create_step().
		 * as it's not set yet
		 */
		$reset_w = 'group-avatar' === bp_action_variable( 1 );

	// User's change avatar screen.
	} else {
		$reset_w = bp_is_user_change_avatar();
	}

	// A user or a group is cropping an avatar.
	if ( true === $reset_w && isset( $_POST['avatar-crop-submit'] ) ) {
		$posts_query->set( 'w', 0 );
	}
}

Changelog

Changelog
Version Description
BuddyPress 2.2.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.