Skip to content
Docs
Get RestroPress

Filter

rpress_current_location_id

Updated
On this page

Filters the ID of the branch the customer is ordering from.

rpress_get_current_location_id() reads the branch cookie, then default_location from the RestroPress settings, then from the Multi-Location settings, and otherwise returns 0. The value is a Multi-Location term ID. The store hours engine uses it when no branch is passed in. The cookie is visitor-controlled, so do not treat the value as authorization.

Available since RestroPress 3.5.1.

Parameters#

ParameterTypeDescription
$location_idintBranch term ID, or 0.

Return value#

int. Branch term ID, or 0. Passed through absint().

Example#

add_filter( 'rpress_current_location_id', 'my_current_location', 10, 1 );
function my_current_location( $location_id ) {
	if ( 0 === $location_id && is_user_logged_in() ) {
		$location_id = absint( get_user_meta( get_current_user_id(), 'my_preferred_branch', true ) );
	}
	return $location_id;
}

Source#

Applied in:

  • includes/rp-core-functions.php (line 331), in rpress_get_current_location_id()

See also#

Was this page helpful?