Skip to content

Instantly share code, notes, and snippets.

@finalwebsites
Last active May 6, 2022 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save finalwebsites/454e8f2a2e6e9db011db5122ebc850d2 to your computer and use it in GitHub Desktop.
Save finalwebsites/454e8f2a2e6e9db011db5122ebc850d2 to your computer and use it in GitHub Desktop.
This snippet will redirect the WordPress admin to the user profile page after a new user was added.
<?php
// place this code snippet to the functions.php file from your WordPress child theme
add_action("current_screen", "redirect_user_add");
function redirect_user_add() {
if (!empty($_GET['id'])) {
$currentScreen = get_current_screen();
if ($currentScreen->id == "users") {
wp_redirect( admin_url("/user-edit.php?user_id=".(int)$_GET['id']) );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment