Want create site? Find Free WordPress Themes and plugins.

If you require a user to login on your WordPress site, you might want to redirect them to a specific page upon successful completion.

Code Snippet:

Add this function below in functions.php file.

function my_login_redirect( $redirect_to, $request, $user ) {
	//is there a user to check?
	if ( isset( $user->roles ) && is_array( $user->roles ) ) {
		//check for admins
		if ( in_array( 'administrator', $user->roles ) ) {
			// redirect them to the default place
			return $redirect_to;
		} else {
                        // redirect users to home page
			return home_url();
	} else {
		return $redirect_to;

add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face – we are here to solve your problems.

Did you find apk for android? You can find new Free Android Games and apps.
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

Posted by Editorial Staff