• Hi I want to redirect the author archive to the user’s website I have tried looking for this but nothing comes up that relates to this

    I use a sso (oneall) plugin that adds the URL of the linked profile

    • This topic was modified 4 years, 7 months ago by Steven Stern (sterndata).
    • This topic was modified 4 years, 7 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Everything else WordPress topic
Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Add this code to your theme’s (preferably a child theme) functions.php:

    add_filter('request', function ( $req ) {
            // if author archive request then redirect to author's site
    	if (array_key_exists('author_name', $req )) {
    		$url = get_user_by('slug', $req['author_name'])->user_url;
    		if ('' != $url ) {
    			wp_redirect( $url, 302 );
    			exit;
    		}
    	}
    	return $req;
    });

    This uses the user URL that’s stored with the WP_User object which is input from the default user profile screen. I don’t know anything about the URL from your SSO plugin, so my code may need adaptation to use the URL you want.

Viewing 1 replies (of 1 total)
  • The topic ‘Redirect author archive to users website’ is closed to new replies.