Site icon Hip-Hop Website Design and Development

Redirect to login when on non-public web page, and when logged in to particular web page

I´m utilizing a plugin referred to as “non-public content material login redirect”.

The plugin is definitely solely containing this piece of code:

    add_action('template_redirect', 'private_content_redirect_to_login', 9);
perform private_content_redirect_to_login() {
  world $wp_query,$wpdb;
  if (is_404()) {
    $non-public = $wpdb->get_row($wp_query->request);
    $location = wp_login_url($_SERVER["REQUEST_URI"]);
    if( 'non-public' == $private->post_status  ) {
      wp_safe_redirect($location);
      exit;
    }
  }
}

What it does is that this: When a non-logged in consumer is viewing a non-public web page, it redirects them to the log-in web page. After they log in, they’re taken again to the non-public web page they simply visited and may learn it.

I would love it to redirect them to log-in web page, however after they have logged in, they need to be taken to a selected web page (ex http://www.testsite.com/begin) as a substitute of the non-public web page they visited.