Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Hide specific locations from users in Post to GMB plugin
It is possible to limit the location list to specific locations (or a single location) using the mbp_get_locations filter.
We can use it to filter out the locations that don't belong to the website or user.
The code loops through all locations and checks whether the location is within an array of allowed locations. If not, it is removed (hidden).
You can find the location ID by right clicking the location in the location selector, and pressing "Inspect Element":
function remove_unwanted_locations($locations){
$allowed_locations = array(
foreach($locations->locations as $key => $location){
if(!in_array($location->name, $allowed_locations)){
return $locations;
add_filter('mbp_get_locations', 'remove_unwanted_locations');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment