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();
}
}
Related Posts:
- redirect 301 old url to new url
- How to rewrite url wordpress?
- wordpress url correction
- Two sets of url one content?
- URL problem: www.sitename.com/blog and www.sitename.com/learn using same WP installation
- WordPress is adding “category” word before my actual category name in url (and this is unsolicited)
- How to retrive previous Domain URL in Wp
- Lost WordPress website access after changing URL [closed]
- WordPress is adding pagination for all pages like www.example.com/page/123. How to remove that?
- Use a template file for a specific url without creating a page
- Override default url for author pages?
- Getting the Site URL Including the Front Base
- Multiple endpoints to same page
- Rewrite default post type
- How to prevent redirection to max 2147483647 for larger values of the page query variable?
- How to create a specific frontend URL (not a Page) from a theme or plugin?
- how to add prefix to post url structor only
- Why does wordpress still strip my query var?
- WP Login forms action URLs displayed as pretty URLs in browser (ex with Restore Password)
- Passing & Reading URL Parameters with URL re-writing
- Add_query_arg + two times the same argument?
- Woocommerce different URL for every table placed in the restaurant
- Change default URL of image attachment
- Prevent WordPress from automatically correcting URLs
- Taking a value from PHP_URL_PATH won’t work after WordPress 5.5 update
- Display content according to current URL
- Server (WordPress) redirects files that are not supposed to (using htaccess)
- Change WordPress comments url / word
- Allow single quote in URLs
- Changing WordPress blog name and web address
- How to check current URL for endpoint in a template file?
- add_rewrite_rule not working for language specific characters
- Custom URL rewrite to specific page template
- Custom user profile URLs
- Alias ‘wp-content’ directory to something shorter (framework?)
- WordPress .htaccess – route other URLs to another app
- WordPress plugin Write User/staff ID as the same as the WordPress User ID
- open all .docs in word online
- How to add custom variable in url without redirect?
- Adding pretty query parameters
- Changing RSS feed URL structure
- Creating a dynamic URL structure
- How to change the main site url on a multisite installation (network)?
- Append a query string to the end of every URL
- How to disable URL rewriting for specific URLs?
- Adding special characters to slug?
- How do I retain url parameters the entire time a user browses my site?
- Rewrite custom post type URL parameters
- Wildcard forward all posts and pages with few exceptions
- Help with Rewrite Rule for Custom Post Type with Query String
- Translate custom post type and taxonomy slug in URL?
- Right url for custom post type
- Preserve old website URL structure after migrating to WordPress
- Change pagination url format
- React Router with WordPress
- How to redirect large amount of URLs?
- How to achieve my custom post url structure?
- How to create a front end user profile with a friendly permalink and a 404 trigger
- Changing URL scheme, mod_rewrite not helping
- ngnix Url rewrite doesn’t work
- Understanding the query string after .htaccess rewrite
- Is WordPress API visible from PHP file called in htaccess
- custom wordpress rewrite
- Flushing rewrite rules
- Replace “http://localhost:8888/” by website URL in WordPress
- How to customize sub-URLs in a wordpress website (.htaccess)
- Rewriting a date hierarchy into a ‘yyyy-mm-dd’ slug
- custom url – add attachment’s id or name after post
- How do I get posts to appear at mydomain.com/blog?
- get variable from url?
- Make the home page’s slug visible in the browser’s URL bar
- loading images, css and fonts from site url
- dynamic URL rewrite
- How to change search page url so that it still returns a page when there’s no search query specified?
- WP returns to domain root instead of siteurl
- Multisite problem with unexisting paths to CSS etc
- SEF add_rewrite_rule & add_rewrite_tag not working
- Problem building an url with argument
- How to Update / Change URL when Popup Modal Loads?
- Multiple permalink with and without category for same post
- There is how to change url domain on some posts?
- How do I rewrite URL that has custom parameter
- url redirect none www to www
- Rewrite URL to get rid of wp-content etc and change URL
- Homepage cannot be found
- How to remove Base URL Duplication?
- Get custom posts by segment of the URL
- Pagination appearing twice in URL after rewrite
- Use Parent Pages for URL Structure without Landing Page
- Add dynamic url with external page in WordPress
- URL Rewrite for CPT single posts
- Custom Rewrite for Profiles
- WordPress post-type create url rewriting
- Can I exclude a single URL from a rewrite plugin?
- How can i maintain permalink structure and avoid a 404 error when loading external content?
- How to prevent URL-modification when page title contains digits only?
- How do I display a friendly URL link in the frontend?
- Please give me the rewrite rules for my ugly urls
- Remove url parameter using wordpress
- Spurious URL structure (Adding extra /0/s)