I am trying to add a function to my child theme to append the currently logged user as a parameter. For example, when the user test1 logs in and clicks on the following page:
http://www.example.com/my-wishlist
I want her to be redirected automatically to
http://www.example.com/my-wishlist/?user=test1
So far I did the following but it ends in a loop:
$current_user = wp_get_current_user();
if ( is_user_logged_in() ) {
wp_redirect( 'http://www.example.com/my-wishlist/?user='.$current_user->user_login );
exit;
}
I would appreciate some help. Thank you