Skip to content

Instantly share code, notes, and snippets.

@KaineLabs
Last active May 25, 2019 18:45
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 KaineLabs/be2cdc05589253cf1c0f749c9f05dcd8 to your computer and use it in GitHub Desktop.
Save KaineLabs/be2cdc05589253cf1c0f749c9f05dcd8 to your computer and use it in GitHub Desktop.
Redirect User Profile Page URL
<?php
/**
* Redirect User Profile Page URL
*/
function yzc_redirect_user_profile_url() {
if ( current_user_can( 'administrator' ) ) {
return false;
}
global $pagenow;
if ( $pagenow == 'profile.php' ) {
// Get User ID.
$user_id = bp_loggedin_user_id();
// Get Current User Domain.
$user_domain = bp_core_get_user_domain( $user_id );
// Get Profile Url.
$profile_url = $user_domain . bp_get_profile_slug() . '/';
// Redirect to profile.
wp_redirect( $profile_url );
exit;
}
}
add_action( 'admin_init' , 'yzc_redirect_user_profile_url' );
@m-Fridge
Copy link

I'm a noob, how do I integrate this to my site? I downloaded a plugin to turn the code into a shortcode, inserted it into a page, but no luck.
I also uploaded this code in a file called "profile.php" to my current themes dir, not sure how to call it though. Do I need to change anything in the code to get it to work?

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