bp_sanitize_pagination_arg( string $page_arg = '', int $page = 1 )

Sanitizes a pagination argument based on both the request override and the original value submitted via a query argument, likely to a template class responsible for limiting the result set of a template loop.

Parameters Parameters


(string) (Optional) The $_REQUEST argument to look for.

Default value: ''


(int) (Optional) The original page value to fall back to.

Default value: 1

Top ↑

Return Return

(int) A sanitized integer value, good for pagination.

Source Source

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

function bp_sanitize_pagination_arg( $page_arg = '', $page = 1 ) {

	// Check if request overrides exist.
	if ( isset( $_REQUEST[ $page_arg ] ) ) {

		// Get the absolute integer value of the override.
		$int = absint( $_REQUEST[ $page_arg ] );

		// If override is 0, do not use it. This prevents unlimited result sets.
		// @see https://buddypress.trac.wordpress.org/ticket/5796.
		if ( $int ) {
			$page = $int;

	return intval( $page );

Top ↑

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.