How can add username to url in WordPress?

Rate this post

Guys is there a way to get username of the logged in user and append it with site url such as

How can we do this in functions.php?



/* you should try below code to get userid of logged in user and redirect to page with username in URL */
    $curret_usedata = get_userdata(get_current_user_id());
            $uname= $current_usedata->user_login;
            $redirectUrl = get_site_url().'/username='.$uname;
            /* redirect code here */


Leave a Reply

Your email address will not be published.

Back to top button