Title: Change Events URL Slug programmatically
Last modified: May 29, 2020

---

# Change Events URL Slug programmatically

 *  Resolved [laiconsulting](https://wordpress.org/support/users/laiconsulting/)
 * (@laiconsulting)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/change-events-url-slug-programmatically/)
 * I have a multisite setup, would like to change the Events URL slug from /events
   to something else programmatically, so subsite owners don’t need to bother with
   it.
    Is this doable?

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [Santiago](https://wordpress.org/support/users/sjaure/)
 * (@sjaure)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/change-events-url-slug-programmatically/#post-12919704)
 * Hi [@laiconsulting](https://wordpress.org/support/users/laiconsulting/),
    Thanks
   for reaching out,
 * If I understand correctly you don’t want to have the site owners to change the
   slug but instead changing it automatically by code?
 * The events slug is stored in the table wp_options (for each subsite wp_x_options)
   under the option name ‘tribe_events_calendar_options’ in a serialized array. 
   Changing that manually would be highly discouraged unless you know exactly what
   you are doing.
 * Now, there you could use the method [set_option](https://docs.theeventscalendar.com/reference/classes/tribe__settings_manager/set_option/)
   wraped in a function and hooked in your functions.php
    Something like this would
   work to keep the slug set to ‘mySlug’ everytime the site loads.
 * add_filter(‘init’, ‘tribe_set_events_slug’);
    function tribe_set_events_slug (){
   Tribe__Settings_Manager::set_option( ‘eventsSlug’, ‘mySlug’ ); }
 * Let me know if this helps
 * Best
    Santiago
 *  Thread Starter [laiconsulting](https://wordpress.org/support/users/laiconsulting/)
 * (@laiconsulting)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/change-events-url-slug-programmatically/#post-12920679)
 * [@sjaure](https://wordpress.org/support/users/sjaure/)
    many thanks for the code
   snippet. That’s very helpful. May I ask one more question.
 * How do I change the default google map api key without editing plugin code?
    
   I’d like subsites to inherit one key without users having to deal with setting.
   If there is a constant to define, that would be ideal.
 * I have come up with the following code, but it doesn’t work somehow.
 *     ```
       add_filter( 'tribe_field_value', 'bv_populate_field_with_default_api_key' , 8, 2 );
       function bv_populate_field_with_default_api_key( $value_string, $field_name ) {                                                                                                                                 
       if ( ! isset( $field_name ) || 'google_maps_js_api_key' !== $field_name ) {
               return $value_string;
       }
   
       if ( ($value_string == "AIzaSyDNsicAsP6-VuGtAb1O9riI3oc_NOb7IOU" || empty( $value_string )) && function_exists('tribe_update_option') ) {
   
               remove_filter( 'tribe_field_value', array( $this, 'bv_populate_field_with_default_api_key' ), 8, 2 );
               $value_string = GOOG_MAP_KEY;
               tribe_update_option(  'google_maps_js_api_key', GOOG_MAP_KEY );
   
               add_filter( 'tribe_field_value', array( $this, 'bv_populate_field_with_default_api_key' ), 8, 2 );
       }
       ```
   
 *  [Santiago](https://wordpress.org/support/users/sjaure/)
 * (@sjaure)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/change-events-url-slug-programmatically/#post-12922886)
 * Hey [@laiconsulting](https://wordpress.org/support/users/laiconsulting/) ,
 * I’m happy to hear it helped.
    The following snippet will set the default API 
   key whenever a custom one is not set.
 * add_filter(‘init’, ‘tribe_set_google_api_key’);
    function tribe_set_google_api_key(){
   Tribe__Events__Google__Maps_API_Key::$default_api_key = ‘asdasdasdasdasdasdasdasd’;}
 * Let me know how it goes
    Best
 *  Thread Starter [laiconsulting](https://wordpress.org/support/users/laiconsulting/)
 * (@laiconsulting)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/change-events-url-slug-programmatically/#post-12926827)
 * Many thanks again for the help!
 *  Thread Starter [laiconsulting](https://wordpress.org/support/users/laiconsulting/)
 * (@laiconsulting)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/change-events-url-slug-programmatically/#post-12956646)
 * [@sjaure](https://wordpress.org/support/users/sjaure/)
    I have a strange problem
   regarding to setting the default api key When I run `Tribe__Events__Google__Maps_API_Key::
   $default_api_key`, it displays the key I want to be used, however when I look
   in the DB directly, it is still the default TEC key. And what is used by the 
   map widget is still the TEC api key, not mine.
 * Is that a way to remedy it?
    Or filter it to my key somehow?
 *  Thread Starter [laiconsulting](https://wordpress.org/support/users/laiconsulting/)
 * (@laiconsulting)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/change-events-url-slug-programmatically/#post-12956673)
 * Nevermind.
    Based on your previous snippet, I added this line. `if( Tribe__Settings_Manager::
   get_option("google_maps_js_api_key") != GOOG_MAP_KEY ) Tribe__Settings_Manager::
   set_option("google_maps_js_api_key",GOOG_MAP_KEY);` It does the job
 *  [Santiago](https://wordpress.org/support/users/sjaure/)
 * (@sjaure)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/change-events-url-slug-programmatically/#post-12962781)
 * Hi [@laiconsulting](https://wordpress.org/support/users/laiconsulting/),
 * I’m happy to hear you sorted it out.
    Thanks for sharing the solution.
 * Cheers

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Change Events URL Slug programmatically’ is closed to new replies.

 * ![](https://ps.w.org/the-events-calendar/assets/icon-256x256.gif?rev=2516440)
 * [The Events Calendar](https://wordpress.org/plugins/the-events-calendar/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/the-events-calendar/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/the-events-calendar/)
 * [Active Topics](https://wordpress.org/support/plugin/the-events-calendar/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/the-events-calendar/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/the-events-calendar/reviews/)

## Tags

 * [filter](https://wordpress.org/support/topic-tag/filter/)
 * [multisite](https://wordpress.org/support/topic-tag/multisite/)
 * [URL slug](https://wordpress.org/support/topic-tag/url-slug/)

 * 7 replies
 * 2 participants
 * Last reply from: [Santiago](https://wordpress.org/support/users/sjaure/)
 * Last activity: [6 years, 2 months ago](https://wordpress.org/support/topic/change-events-url-slug-programmatically/#post-12962781)
 * Status: resolved