Skip to content

Instantly share code, notes, and snippets.

@vanbo
Created February 17, 2015 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vanbo/4e93512b8d95e03b1ef2 to your computer and use it in GitHub Desktop.
Save vanbo/4e93512b8d95e03b1ef2 to your computer and use it in GitHub Desktop.
Skip activation page on MultiSite - Activate header
add_action( 'activate_header', 'check_activation_key_redirect_to_page' );
/**
* Check the wp-activate key and redirect the user to home page.
*/
function check_activation_key_redirect_to_page() {
// We check if the key is not empty
if ( ! empty($_GET['key']) && ! empty($_POST['key']) ) {
$key = !empty($_GET['key']) ? $_GET['key'] : $_POST['key'];
// Activates the user and send user/pass in an email
$result = wpmu_activate_signup($key);
if ( ! is_wp_error($result) ) {
extract($result);
$user = get_userdata( (int) $user_id);
// Start session if it was not started
if ( ! session_id() )
session_start();
// Save the user object to the session
$_SESSION['my_active_user_variable'] = $user;
// Redirect to the network home url
wp_redirect( network_site_url() );
exit;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment