Default Venue Country

Home Forums Calendar Products Community Events Default Venue Country

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #948528
    Jonny
    Participant

    Hi there.

    I’ve looked in the knowledge base and can’t find a solution for this.

    On the front-end form I wish to exclude all countries from the venue location dropdown other than the UK.
    Basically, the project only accepts UK submissions to would.
    Also, when selecting the UK, the US state still shows.
    I would just hide this with css but it doesn’t seem to have an identifying class.

    Can you help/suggest?

    Thanks,
    Jonny

    #953651
    Tony
    Participant

    I too would like to know the answer to this question

    #953682
    Jonny
    Participant

    No reply within 3 weeks. Support, please could you advise either way regarding this?

    #954897
    George
    Participant

    Jonny, I am so sorry about this delayed response! It was a mistake on my part, I assigned this issue to myself back a while ago, and I was filtering my queue of support tickets by the last person to reply to the ticket – I had that limited to the original poster, so the ticket slipped through the cracks, and then didn’t come back on my radar until you posted again now. I am so sorry.

    I am also sorry because despite all this, there isn’t good news here – I took a deep dive into the good to look for any way to change the default country, and it turns to be quite easy in every place BUT the Community Events submission form.

    It is indeed possible if you head right into the core plugin code and modify it directly – something that is very much not recommended, but if you need this functionality, it’s a workable solution until he have a filter or something else in place that would make this easy.

    Is editing the core plugin code directly something you’re interested in? If so, I can share the code to do so. If not, then at the very least your issue here has revealed some things we can definitely improve in the Community Events add-on.

    I’m very sorry Jonny. Let us know what you think here.

    Thank you,
    George

    #954967
    Jonny
    Participant

    Hey George,
    I guess these things happen. It’s a big internet!
    Hmmmm not to keen on hacking core but I’d appreciate the code. If I do not use it myself may help someone here.

    Thanks

    #955059
    George
    Participant

    Thanks for being so cool about this Jonny, it means a lot and I promise if you ever post in these forums again you will not face such an awful delay in response times!

    Now, on to editing the code: This is fortunately a core customization that, while not technically recommended – and something that will be overwritten the next time you update the plugin – is quite simple.

    If you look for the TribeViewHelpers class in /the-events-calendar/lib – notice how this is not community events itself, but the core plugin – you should find a method in this core class called constructCountries().

    Should look something like this → https://cloudup.com/crRE-SHfREt

    All you have to do here is edit that $countries array – if you just want United Kingdom to be the first element there, but leave everything else intact, you can just go down the list until you find the item for United Kingdom, which looks like this:

    
    "GB" => __( "United Kingdom", 'tribe-events-calendar' ),
    

    And move it above the listing for the United States.

    If you want to go further and get rid of most of the other countries listed there, you can just delete them and keep the items you want.

    Save the file, and when you head back to the community events submission page, or any other country-selection field on your site, the changes you made should be reflected there.

    I hope this helps!

    Cheers Jonny

    #955340
    Tony
    Participant

    Jonny,

    If you have the Pro version of the plugin, go to Settings and under the Default Content tab in the Address section add ‘UK, United Kingdom’ to Use a custom list of countries – this will limit the list to just UK.

    Setting a default country is not needed if UK is the only option (which doesn’t work anyway – bug).

    There is also a bug that causes the US States select list to still display and the only way I know to get rid of this is to remove or comment it out by overriding the module file in your theme (see below).

    Initially I did not have the Pro version of the plugin, so to achieve getting UK as the default, I did the following…

    I created some folders in my theme to override the submission form without modifying the plugin files…

    /tribe-events/community/modules

    …in which I have placed a copy of venue.php taken from the equivalent folder in the plugin.

    In this file, there does appear to be an attempt to get the default country…

    $venue_country = empty( $venue_country ) ? tribe_get_option( 'defaultCountry' ) : $venue_country;

    …but it does not work.

    So I have replaced the code with…

    $venue_country = empty( $venue_country ) ? 'United Kingdom' : $venue_country;

    I also had to change the opening if statement from…

    if ( !tribe_get_venue_id() && tribe_get_option( 'defaultValueReplace' ) ) {

    to…

    if ( !tribe_get_venue_id() ) {

    This will at least set the default country to the UK.

    As there also seems to be a bug in the code that hides the US State select list, I have simply commented the select tag out of my page for now as it is not needed.

    I hope this helps.

    #955402
    George
    Participant

    Hey Jonny,

    Tony’s method may work for you, and both options here should be helpful. Thanks for offering that suggested modification Tony.

    #984015
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Default Venue Country’ is closed to new replies.