Hi,
It is not recommended to remove %username% parameter from the URL as it is required parameter to load the data of that user in the profile page.
If you want to allow access to own profile page only and redirect to home page while accessing other profile page then you can put following code in your functions.php file of the currently active theme.
add_action('template_redirect', 'uwp_profile_page_redirect', 99);
function uwp_profile_page_redirect(){
if (!is_page()) {
return false;
}
global $wp_query, $post;
$current_page_id = $post->ID;
$profile_page = uwp_get_option('profile_page', false);
if ( $profile_page && ((int) $profile_page == $current_page_id ) ) {
if (isset($wp_query->query_vars['uwp_profile'])) {
$url_type = apply_filters('uwp_profile_url_type', 'slug');
$author_slug = $wp_query->query_vars['uwp_profile'];
if ($url_type == 'id') {
$user = get_user_by('id', $author_slug);
} else {
$user = get_user_by('slug', $author_slug);
}
if (isset($user->ID) && is_user_logged_in() && $user->ID == get_current_user_id()) {
return false;
} else {
wp_redirect( home_url('/')); // redirect for other users
exit();
}
}
}
return false;
}
Let me know if it helps you.
Regards,
Patrik