Support

Home Forums Event Espresso Premium Show State Name instead of Code in Venue Address

Show State Name instead of Code in Venue Address

Posted: May 14, 2015 at 1:40 am


Geoff Murrey

May 14, 2015 at 1:40 am

By default the Venue Address displays the State Code.
In the UK we would never show this – they wouldn’t mean anything to anyone.
I found a similar question on these forums but it was not resolved.
(The suggestion was to use a shorter name as the code)
It’s hard to believe that this requirement hasn’t made it through to the product.
In the meantime I will dig about in the code, but would like to have an official way, or at least get it put on the TODO list…


Dean

May 14, 2015 at 4:40 am

Hi Geoff,

As one of 2 Brits on the team, and with me also living in a different EU country with even different requirements, this was something we were also concerned about.

What the developers have done is allowed the code section of the states/regions/provinces/countries to be larger. This means that instead of a limited 6 character code, you can put (almost) what you want there and it will show instead.

So what I have done is simply replace the codes with the counties. Screenshot http://take.ms/4pUfZ

Going from this: http://take.ms/xdMOx (showing the weird code)
to this: http://take.ms/Pipca (showing the county name)

This should have been from 4.6.20 onwards, but updating to the latest version will mean you definitely have access to that change.

Does that help? Anything else I can help with regarding this topic?


Geoff Murrey

May 14, 2015 at 4:57 am

Hi Dean,
Many thanks for the response.
That is *a* workaround, but I think it’s a poor choice as it needs a fair bit of manual editing and it in’t the right way.

I tracked down this code (line 185, core/db_classes/EE_Venue.class.php)
and commented out the bit I didn’t want to execute.

This works for me 🙂
However the code indicates that a filter is applied to change this.
If I knew a little more about the WordPress system I could probably write my own plugin that removes this filter.
I’m surprised it isn’t a configuration though.

/**
* either displays the state abbreviation or the state name, as determined
* by the “FHEE__EEI_Address__state__use_abbreviation” filter.
* defaults to abbreviation
* @return string
*/
public function state() {
/*if ( apply_filters( ‘FHEE__EEI_Address__state__use_abbreviation’, true, $this->state_obj() ) ) {
return $this->state_abbrev();
} else */ {
return $this->state_name();
}
}

I’m now hunting through the code to find where I can remove the Country completely (from the formatted address) as all events will be in UK and thus redundant.
Even if I were to leave it in, I wouldn’t want it showing before the Postcode – this just isn’t right.
e.g. The Italian Villa, 164 Canford Cliffs Road, Poole, Dorset, GB, BH13 7ES

Again, this seems like a relatively easy job for the developers to add a little more configuration.


Geoff Murrey

May 14, 2015 at 5:13 am

Just for reference if anyone else needs to do these things..

For the Country removal I commented out the line from the following function

	public function format( $address, $address2, $city, $state, $country, $zip ) {
		$formatted_address = $address;
		$formatted_address .= substr( $formatted_address, -2 ) != ', ' ? ', ' : '';
		$formatted_address .= ! empty( $address2 ) ? $address2 : '';
		$formatted_address .= substr( $formatted_address, -2 ) != ', ' ? ', ' : '';
		$formatted_address .= ! empty( $city ) ? $city : '';
		$formatted_address .= substr( $formatted_address, -2 ) != ', ' ? ', ' : '';
		$formatted_address .= ! empty( $state ) ? $state : '';
		$formatted_address .= substr( $formatted_address, -2 ) != ', ' ? ', ' : '';
		/*$formatted_address .= ! empty( $country ) ? $country : '';*/
		$formatted_address .= substr( $formatted_address, -2 ) != ', ' ? ', ' : '';
		$formatted_address .= ! empty( $zip ) ? $zip : '';
		return $formatted_address;
	}
}

Line 205: /core/helpers/EE_Formatter.helper.php

Hopefully I’ll find a better way before the plugin gets updated and I lose my changes..


Dean

May 14, 2015 at 6:29 am

Nice catch with the filter, I wasn’t aware of that one (we have so many of them…)

This function can be added to a site specific plugin or Child your themes functions.php file:

function uk_venue($bool, $obj) {
  $bool = false;
  return $bool;
}
add_filter( 'FHEE__EEI_Address__state__use_abbreviation', 'uk_venue', 10, 2);

That will then toggle the use of the county codes.

Site specific plugin info: https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/

Regarding the country, I can’t see a way to remove it, though adding this filter to below the above code will change it from GB to United Kingdom.

add_filter('FHEE__EEI_Address__country__use_abbreviation', 'uk_venue', 10, 2);

I’ll request a filter to remove the country from the address.


Geoff Murrey

May 14, 2015 at 6:38 am

Nice one, thanks Dean


Lorenzo Orlando Caum

  • Support Staff

September 12, 2015 at 11:31 am

Hi Geoff,

We wanted to let you know about an enhancement in the current version of Event Espresso 4 that offers more flexibility for venue addresses.

First, please backup your WordPress site and upgrade to the latest release of Event Espresso 4:

https://eventespresso.com/wiki/ee4-changelog/

Next, there is some sample code in this link:

https://gist.github.com/lorenzocaum/5e2658a1f7e7a9a6b5c0

Here is an explanation of the sample code:

In the older versions of Event Espresso, you could change the formatting for the venue address. However, this would apply to all venue addresses. The new enhancement is more flexible as it allows you to change the formatting for certain countries.

In the example code, we have an entry for United Kingdom which has a country code of GB. Then we have the actual formatting which doesn’t include the province or the country name.

Just below that, we have an entry for Canada which has a country code of CA. In Canada, the zip/postal code appears as the end of the address so the formatting will show it in that order.

Below that is an entry for Germany which has a country code of DE with a specific formatting for the address.

If you have modified the venue address through an existing function, then you may consider switching to the new one mentioned in the link above.

Thanks!


Lorenzo

The support post ‘Show State Name instead of Code in Venue Address’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso