Created
February 17, 2015 16:18
-
-
Save vanbo/4e93512b8d95e03b1ef2 to your computer and use it in GitHub Desktop.
Skip activation page on MultiSite - Activate header
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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