Redirect WordPress user

This the second tutorial and by starting it slow I am going to show you a small handy function that you will love!

This snippet allows you to redirect login users and check on what WordPress page they currently at. This is useful when you run a Membership website and want your members redirected only to the member’s area and restrict access for some users.

In the previous post, I showed you how to create a child theme and explain what type of files you can add in your child theme. One of the files is “functions.php”.

  1. Open your Child Theme folder and create a file called “functions.php”
  2. Now copy and paste the code below into your functions file.
  3. Replace the is_page( Your Page ID ) with the page you want. For example, when your members land on the home page and they are logged in, redirect them to the member’s area.
    1. To get your page ID read more here. http://bit.ly/2hu7v4J
  4. Replace “/dashboard” with the page you want.
    1. This is the slug of your page. http://bit.ly/2ypeI9s
<?php
if(is_user_logged_in() && is_page( Your Page ID )){
wp_redirect ( home_url("/dashboard") );
exit;
}
coding-699318_1280
Once a week we send a digest with the most popular articles.

We are more than just a Hosting company!

AdminWP Host, Maintain (Site-care), Secure and Backup WordPress websites.