Reputation: 3
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
Upvotes: 0
Views: 256
Reputation: 2525
Change this
wp_redirect( "http://localhost/wordpress/slug/$user->display_name" );
to
wp_redirect( "http://localhost/wordpress/slug/".$user->display_name);
Try to use bloginfo('url')
instead of using localhost/wordpress
Upvotes: 1