Reputation: 779
How can I redirect user from wp-admin
to another custom page, for example I want to redirect this url:
http://example.com/wp-admin
to:
http://example.com/custom
Upvotes: 3
Views: 13504
Reputation: 6080
Use following code in your functions.php file to redirect to another URL.
function redirect_login_page(){
// Store for checking if this page equals wp-login.php
$page_viewed = basename($_SERVER['REQUEST_URI']);
// Where we want them to go
$login_page = http://example.com/custom; //Write your site URL here.
// Two things happen here, we make sure we are on the login page
// and we also make sure that the request isn't coming from a form
// this ensures that our scripts & users can still log in and out.
if( $page_viewed == "wp-login.php" && $_SERVER['REQUEST_METHOD'] == 'GET') {
// And away they go...
wp_redirect($login_page);
exit();
}
}
add_action('init','redirect_login_page');
Upvotes: 0
Reputation: 6379
The easiest way would probably be to create a .htaccess
file in your webroot directory
.
Afterwards write this into it:
Redirect /wp-admin http://www.example.com/custom
Quite self explanatory. Redirect
from first link /wp-admin
to second link http://www.example.com/custom
Another way would probably be to use wordpress wp_redirect()
function, something like this:
wp_redirect('http://example.com/custom', $status );
Upvotes: 1
Reputation: 8809
wp_redirect( $location, $status );
exit;
OR try like this
wp_redirect( home_url( '/custom/' ) );
exit();
Upvotes: 1