Title: andersonpg's Replies | WordPress.org

---

# andersonpg

  [  ](https://wordpress.org/support/users/andersonpg/)

 *   [Profile](https://wordpress.org/support/users/andersonpg/)
 *   [Topics Started](https://wordpress.org/support/users/andersonpg/topics/)
 *   [Replies Created](https://wordpress.org/support/users/andersonpg/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/andersonpg/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/andersonpg/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/andersonpg/engagements/)
 *   [Favorites](https://wordpress.org/support/users/andersonpg/favorites/)

 Search replies:

## Forum Replies Created

Viewing 1 replies (of 1 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[The Events Calendar] Limit time zone in dropdown menu?](https://wordpress.org/support/topic/limit-time-zone-in-dropdown-menu/)
 *  Thread Starter [andersonpg](https://wordpress.org/support/users/andersonpg/)
 * (@andersonpg)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/limit-time-zone-in-dropdown-menu/#post-18313933)
 * Thanks! That pointed me in the right direction. If anyone else is interested,
   here is the code I used via a snippets plugin to limit the time zones:
 *     ```wp-block-code
       <?phpadd_filter( 'tribe_events_timezone_choice', 'limit_timezone' );function limit_timezone( $timezone_selector_html ) {    $retain = [        'Honolulu',     // UTC-10        'Anchorage',    // UTC-9        'Los Angeles',  // UTC-8        'Phoenix',      // UTC-7        'Denver',       // UTC-7        'Chicago',      // UTC-6        'New York',     // UTC-5    ];    $html = '';    $lines = explode( "\n", $timezone_selector_html );    $i = 0;    while ( $i < count( $lines ) ) {        $line = $lines[$i];        if ( 0 === strpos( $line, '<optgroup ' ) ) {            // Look ahead to check if the optgroup is empty            $j = $i + 1;            $optgroup_empty = true;            while ( $j < count( $lines ) && 0!== strpos( $lines[$j], '</optgroup>' ) ) {                if ( 0 === strpos( $lines[$j], '<option ' ) ) {                    foreach ( $retain as $acceptable_timezone ) {                        if ( false!== strpos( $lines[$j], ">$acceptable_timezone<" ) ) {                            $optgroup_empty = false;                            break 2;                         }                    }                }                $j++;            }            if (! $optgroup_empty ) {                $html.= "$line\n";             }            $i = $j;         } elseif ( 0 === strpos( $line, '<option ' ) ) {             // Check if this option is in the $retain list            foreach ( $retain as $acceptable_timezone ) {                if ( false!== strpos( $line, ">$acceptable_timezone<" ) ) {                    $html.= "$line\n";                    break;                }            }            $i++;        } else {            $html.= "$line\n";            $i++;        }    }    return $html;}?>
       ```
   

Viewing 1 replies (of 1 total)