I am trying to create a dynamic url that looks like this localhost/wordpress/slug/username
I am using the wp_redirect function to redirect the user to this url but the probleme is that i don't know how to write this url ?
I've tried to create a variable like so $user = wp_get_current_user(); to includ it like so wp_redirect( "http://localhost/wordpress/slug/$user->display_name" ); but the final result is http://localhost/wordpress2/slug/ so please someone help me
keep in mind that i'm writing my code in the function.php file in my theme folder
Thanks
template_redirectaction for actual redirects. Thewp_get_current_userfunction may not be defined if you're calling it too soon.template_redirectis one of the available actions to hook onto.