bp_core_avatar_reset_query( WP_Query|null $posts_query = null )

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


Description 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 Parameters

$posts_query

(Optional) The main query object.

Default value: null


Top ↑

Source 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 );
	}
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.2.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.