From the official code reference:
wp_redirect() does not exit automatically, and should almost always be
followed by a call to exit;
So, you need to call exit after the redirect:
$curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
if ( get_user_role($curauth->ID) === 'subscriber' ):
wp_redirect( 'http://redirect-here.com' );
exit; //here!
endif;
Related Posts:
- How can I disable author pages without 301 redirects?
- redirect “about author” code to about page
- 301 Redirect /author/username/ to /profile/username/
- How to avoid redirect 302 in wordpress to the author pages?
- Author Archive Page redirecting issue
- How can public access to WordPress query (e.g. author=) URLs be redirected?
- When I change slug, will WordPress create redirect from the old URL?
- Why am I getting a 301 on a existing post?
- Non-WordPress page in subdirectory under WordPress page
- Keeps on redirecting on my development copy
- Password change when the user login first time
- Custom login form redirect to external site
- Clarification on auth_redirect()
- Exclude a path from WordPress using .htaccess redirects (Apache)
- Restrict Access to wp-login.php
- Redirect to custom URL after registering from a page with registration form
- Stop unwanted WP redirection to new url
- Problem to redirect custom page using htaccess
- WordPress within a subdirectory of another WordPress environment doesn’t work
- WordPress Customizer: custom redirection after closing
- Website redirecting to old domain name
- How to do 301 redirect to Sub page using htaccess file?
- Does WordPress automatically redirect url without parent slug?
- Redirect guest if he tries to access a specific page
- htaccess 301 redirect http to https doesn’t work
- Site redirecting from http to https [closed]
- Localhost wordpress site redirects to public site
- Use htaccess to redirect WordPress to static website in a subfolder
- Defining a custom 404 for non-WordPress parts of site
- Redirect homepage ( www.sitename.com ) to the latest post
- How to redirect URL with subfolder to the same URL but without subfolder?
- What is the right way to redirect all traffic to HTTPS?
- Site loads very slowly (4-5 minute load time)
- If User is NOT Logged in and Page ID is not 6 – Redirect to Login
- Snippet for own (gr)avatars
- Front end user creation form! How do you keep the user on the same page in event of error?
- URL redirect problem
- 503 Service Unavailable error was encountered
- SSL and www to non-www redirection works only on homepage – WordPress
- How to redirect if a background request is still being executed
- WP site in infinite redirect loop
- WordPress keeps redirecting subpages without http to https homepage after switch
- Redirect non-existent subpages to second part of url
- How to remove the [L] Flag for WordPress index .php mod_rewrite
- ReDirect subfolder link to another sub-folder and force SSL
- How do I remove the RSS Feed Redirect?
- Why does WordPress redirect when I separate wp-core and wp-content?
- Redirect user to original url after login?
- User redirect to specific URL after logging in
- What is the most efficient (ie. less server intensive) way for 301 redirects?
- A WordPress site with more than one domain name / Parked domains
- Redirect user if they are not logged in
- BuddyPress – Redirects on Login and Logout
- How to redirect a wrong search on my wordpress website to the error 404 page?
- store URL global before we redirect
- Redirect to page for KPI/marketing purpouses
- Will deleting WP’s code in .htaccess cause problems?
- adding GET variables to a header() location in a page template
- Migrating to Tumblr [closed]
- Parked domain redirect
- WordPress CSS/Theme gone after SSL got activated
- Redirect 301 of old urls to wordpress urls
- Redirecting DNS without breaking everything
- How to redirect non existent pages/posts in wordpress using htaccess
- redirect doesn’t work while using example code
- redirect second domain to static page
- 301 redirect after removing language directories
- wp_login_form() redirect same page
- Redirect user after login to prior page through a wp_login hook
- Redirect *.php to path using web.config file
- How can force redirected to login for two or more pages to view or access
- WordPress not linking correctly with .htaccess redirect to subdirectory
- WordPress installed on a virtual machine and behind a reverse proxy is redirecting to the VM’s IP address
- wp_redirect() not redirecting user to supplied URL
- How to redirect?
- How to disable WordPress URL autocomplete / recognition?
- Some links keeps redirecting to another domain
- Redirect user on login using extra field value on login form
- Redirect every link that starts with
- login redirect problem – db charset issue?
- Custom login-form redirect
- Link to another website with the same url path
- Redirect to Page after Login (with variable)
- I have cloudflare flexible enabled, How to redirect to https for Nginx server
- Tag archive page not working
- How to move a https website back to dev and access the admin?
- Why is WordPress redirecting to homepage after GET form submit?
- Redirect after user changes password
- How to redirect author subdomain pages to each author pages on www
- Custom Form Redirects to Post after Submit
- Plugin redirects URL structure using 301 redirect. Time to disable the plugin?
- URL is redirecting (301) when query string is passed through URL
- Plugin html-on-pages: URL not redirecting
- Hide page for user logged and redirect for profile? [duplicate]
- Redirect a WP to another with all URL
- Redirect ignore last URL segment
- Creating custom link that redirects to a another link
- How to redirect users without permission to view content to a custom page?
- redirect the root of a domain, while leaving the www version unredirected
- How to Create Custom Route to a page in WordPress