Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wp-user-manager/4a31e4f085b8f8a6fed3a1c79a0fd69d to your computer and use it in GitHub Desktop.
Save wp-user-manager/4a31e4f085b8f8a6fed3a1c79a0fd69d to your computer and use it in GitHub Desktop.
WP User Manager - Redirecting the author URL to the user profile
<?php
add_filter( 'author_link', 'wpum_author_link', 10, 2 );
function wpum_author_link( $link, $user_id ) {
$user = new \WP_User( $user_id );
return wpum_get_profile_url( $user );
}
@mikesimpson416
Copy link

Very helpful. When added to functions php it broke my site but when added to mu-plugins it worked.

@abdullahshahid4u2
Copy link

Even after adding to mu-plugins it is still breaking my website. Can you help?

@wp-user-manager
Copy link
Author

Can you edit your wp-config.php file to replace this line -

define( 'WP_DEBUG', false );

With these lines -

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

This means that any errors are logged to `/wp-content/debug.log', because some errors are not visible on screen.

More details about that at http://codex.wordpress.org/Editing_wp-config.php#Debug

Can you then retry the process and send me the debug.log file that should be created.

@fothy1990
Copy link

I have placed the code in a new file called 'wpum_redirect_author_url_to_profile.php' in the mu-plugins folder, it redirects correctly when a profile/author link is clicked but if you go directly to the /author/ URL in the address bar, it doesn't redirect.

Any ideas, please? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment