Skip to content
Docs
Get RestroPress

Filter

rpress_reservation_client_ip

Updated
On this page

Filters the client IP address used for reservation rate limiting.

Returned by rpress_reservation_client_ip(), which starts from REMOTE_ADDR. Use it when the site sits behind a proxy or CDN so that all visitors do not share one address. The result is validated with FILTER_VALIDATE_IP and replaced with 0.0.0.0 when it is not a valid IP address.

Parameters#

ParameterTypeDescription
$ipstringClient IP address taken from REMOTE_ADDR.

Return value#

string. The client IP address.

Example#

function my_reservation_client_ip( $ip ) {
	if ( ! empty( $_SERVER['HTTP_CF_CONNECTING_IP'] ) ) {
		return sanitize_text_field( wp_unslash( $_SERVER['HTTP_CF_CONNECTING_IP'] ) );
	}
	return $ip;
}
add_filter( 'rpress_reservation_client_ip', 'my_reservation_client_ip' );

Notes#

Only trust forwarded-for headers that your proxy sets; otherwise visitors can bypass the limit.

Source#

Applied in:

  • includes/features/reservations/functions.php (line 315), in rpress_reservation_client_ip()

See also#

Was this page helpful?