Redirect subscribe user to home page

Using wordpress hook, we can redirect subscribed user after login to the desired page or home page:
example:

<?php
// redirect subscribers to the home page 
function change_login_redirect($redirect_to, $request_redirect_to, $user) {
  if (is_a($user, 'WP_User') && $user->has_cap('edit_posts') === false) {
    return get_bloginfo('url'); //we can put whatever url to redirect    
  }
  return $redirect_to;
}
 
// add filter with default priority (10), filter takes (3) parameters
add_filter('login_redirect','change_login_redirect', 10, 3);
?>

Comments

comments

Leave a Reply