Possible to set new user's site time zone at user creation using Gravity Forms?

Let's say I have a multisite network running with Buddypress and has Gravity Forms installed with the GF User Registration addon. During new user/site registration, is there ANY way I can have the user set their time zone by selecting from a Gravity Form drop down menu the timezone they want?

Basically, I don't want the user to have to login to WP and then go to General settings to change their time zones. Is there any way of achieving this without having to edit any core WP code?

Topic timezones multisite user-registration Wordpress

Category Web


Quoting from How to get WordPress Time Zone setting? you can set the option 'gmt_offset' with the appropriate offset from UTC.

You should add the option to control it only in you site creation form. If you put it also on user which registers to an existing site (like the main site) users will be able to change the setting on creation, something that only the admin should be able to do.

If your form calls wpmu_new_blog() you can set that option on blog creation from the data given in the form.

function wpse_127265_timezone( $blog_id )
{
    switch_to_blog( $blog_id );
    update_option('gmt_offset',$_POST['gmt_offset']);
    restore_current_blog();
}

add_action( 'wpmu_new_blog', 'wpse_127265_timezone' );

If that data is part of the registration form (meaning that the site is created only after the user activated it) then things get a little more complex and you need to store the data at some other place until the activation is done.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.