Question: I have a running site (Site A).

I want to re-write the site fully to improve everything but, when I'm finished, I don't want to have to get everyone to sign up to the new site.

I wondered if I could create an entirely new site on a different domain (Site B) with a clean install of Wordpress - and then when I'm finished developing the site copy over the following tables from Site A to Site B:
wp\_options
wp\_users
wp\_usermeta

And would all my existing users then have full access to Site B (the new site) ?

Or is there more to it than this?

Thanks

Answer: 
Of course there’s a function for that ([Codex](https://codex.wordpress.org/Function_Reference/switch_theme)):

```
switch_theme( $stylesheet )

```

It:

> 
> Switches current theme to new template and stylesheet names. Accepts
>  one argument: $stylesheet of the theme. ($stylesheet is the name of
>  your folder slug. It's the same value that you'd use for a child
>  theme, something like `twentythirteen`.) It also accepts an additional
>  function signature of two arguments: $template then $stylesheet. This
>  is for backwards compatibility.
> 
> 
> 

And why is that any better? WordPress uses filters and actions for many things. For example, when you switch the theme, the unused widgets will get saved, so you can restore them in new sidebars... All of that won’t be done, if you switch the theme directly in DB.
The only thing that comes to my mind is to do it from the database, so basically after you check the checkbox status, you will have to select the `wp_options` table, you will need to locate two rows **template** and **stylesheet**.

[![enter image description here](https://i.stack.imgur.com/ohCUL.png)](https://i.stack.imgur.com/ohCUL.png)

Then you will have to update `alexandria` for `youThemeName`. That query will look like this:

```
$query = "UPDATE wp_options SET option_value='youThemeName' WHERE option_name='template' OR option_name='stylesheet';";
$wpdb->query($query);

```