I want to get the username of the logged in users in the URL of my wordpress site. Like if user: arvind is logged in, I want to get the url as 'www.wp.com/arvind' or 'www.wp.com?user=arvind'.
Is there any solution for that?
I think this will do what you are looking for.
add_action("template_redirect", 'template_redirect');
function template_redirect() {
global $wp;
if(is_user_logged_in() && !isset($_GET['user'])){
$current_user= get_userdata(get_current_user_id());
wp_redirect(add_query_arg(array('user'=>$current_user->user_login),home_url($wp->request)));
die();
}
}