Redirect WordPress users during login

Normally in WordPress when a user logs in, he is directed to some place in the administrative back end. If he is assigned the role of Subscriber, this usually sends him to his profile page, which isn’t very useful under most circumstances. If he is assigned the role of Contributor, Author, Editor or Administrator, he is directed to the Dashboard screen.

But what if we want to redirect users to a specific page in the back end or some other page on the front end? For example, maybe we have a special page set up just for Contributors. In WordPress we can redirect users based on their roles or capabilities. Here is an example.

function jp_login_redirect_contributors() {
  if ( current_user_can( 'contributor' ) ){
    return '/redirect/path';
add_filter( 'login_redirect', 'jp_login_redirect_contributors' );

In this example, users assigned the role of Contributor are redirected to /redirect/path. WordPress has a number of roles and capabilities built in that we can target, and we can easily create custom roles and capabilities using plugins like Members.

Using these simple methods we can easily create custom workflows that make life easier in WordPress.

Leave a Reply