Created
August 21, 2020 16:37
-
-
Save kodie/d685bfad6feedf3f9fa263b568a48e4d to your computer and use it in GitHub Desktop.
Redirects https://mywebsite.com/profile to current user's author URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Redirects https://mywebsite.com/profile to current user's author URL | |
add_action('wp', 'profile_redirect'); | |
function profile_redirect() { | |
global $wp; | |
$page = trim(strtolower((string) $wp->request), '/'); | |
if ($page === 'profile') { | |
wp_safe_redirect(get_author_posts_url(get_current_user_id())); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment