gavin.sibley Posted May 23, 2012 Share Posted May 23, 2012 Hello, i am trying t set up a redirect depending on the username of the person. I am new to php so not exactly sure how to set it up. i have this so far, what is needed to make this work? <?php &user = GET_$user_login header( 'Location: http://www.mydomain.com/[&user]-manager' ) ; ?> thanks,gavin Quote Link to comment https://forums.phpfreaks.com/topic/263018-php-redirect/ Share on other sites More sharing options...
.josh Posted May 23, 2012 Share Posted May 23, 2012 Where is the user name coming from? It *looks* like maybe you want: $user = $_GET['user_login']; header( "Location: http://www.mydomain.com/{$user}-manager" ) ; exit(); This assumes that you are receiving the user_login from a GET request like www.yoursite.com/thescriptabove.php?user_login=someuser and it will redirect you to for example: http://www.mydomain.com/someuser-manager Quote Link to comment https://forums.phpfreaks.com/topic/263018-php-redirect/#findComment-1348137 Share on other sites More sharing options...
gavin.sibley Posted May 23, 2012 Author Share Posted May 23, 2012 What im trying to do is for each user to be redirected to there own homepage when they click the home page button, obviously there user_login is stored in the database so was hoping there was someway such as this to insert the user_login straight into a url redirector. doesnt seem to like the code above though, giving me a 404 error Quote Link to comment https://forums.phpfreaks.com/topic/263018-php-redirect/#findComment-1348141 Share on other sites More sharing options...
gavin.sibley Posted May 23, 2012 Author Share Posted May 23, 2012 Just to add a bit more info, the redirect is working however its not including the user_login in the url so i am ending up with:- mydomain.com/-manager rather than mydomain.com/(user_login)-manager thanks Quote Link to comment https://forums.phpfreaks.com/topic/263018-php-redirect/#findComment-1348142 Share on other sites More sharing options...
Kays Posted May 23, 2012 Share Posted May 23, 2012 Verify that $_GET['user_login'] is not empty. Quote Link to comment https://forums.phpfreaks.com/topic/263018-php-redirect/#findComment-1348152 Share on other sites More sharing options...
gavin.sibley Posted May 23, 2012 Author Share Posted May 23, 2012 after looking around a bit (thank you google!) i have found this information that i think may help me, but as i said, having no idea about php really doesnt help! ?php global $current_user; get_currentuserinfo(); echo 'Username: ' . $current_user->user_login . "\n"; echo 'User email: ' . $current_user->user_email . "\n"; echo 'User first name: ' . $current_user->user_firstname . "\n"; echo 'User last name: ' . $current_user->user_lastname . "\n"; echo 'User display name: ' . $current_user->display_name . "\n"; echo 'User ID: ' . $current_user->ID . "\n"; ?> is there anyway of using this to do what im trying to do? to get the user_login? thanks, gavin Quote Link to comment https://forums.phpfreaks.com/topic/263018-php-redirect/#findComment-1348154 Share on other sites More sharing options...
.josh Posted May 23, 2012 Share Posted May 23, 2012 You found that code from google? How is that relevant to your code? How does the user login? do you already have a script for that, which works? If so, there should be a session variable with the info for you to use, or else a session variable with an id associated to the user, for you to query your database for the user's name. I'm starting to get the impression you have some 3rd party script you are trying to tweak...is this the case? Quote Link to comment https://forums.phpfreaks.com/topic/263018-php-redirect/#findComment-1348159 Share on other sites More sharing options...
gavin.sibley Posted May 24, 2012 Author Share Posted May 24, 2012 found a solution for it now so no worries and its sort of half and half im trying to create this redirect script to insert into a wordpress page... Quote Link to comment https://forums.phpfreaks.com/topic/263018-php-redirect/#findComment-1348258 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.