Is is possible to redirect a user on front end login to a post that they have created?
I have the form below on the front end which works great to log people in but doesn't quite achieve what I want.
I've created a front end registration process, that creates a new user and a post and fills in certain details into that post. On completion of that process they are sent to the post they just created, which then allows them to front end edit all the details. That works perfectly for first time registrants but I can't quite achieve what I want with people that have already registered and want to login.
When they fill in their details on the form below, I want it to redirect to the post they created when they registered, is this possible?
The users can only ever create ONE post... which is acting as a profile. So I want them to be able to log in and get redirected to their profile.
If it helps, the username is the same as the post title (the username is the persons company name, which is also the name of the post).
<?php if (!(current_user_can('level_0'))){ ?>
<form action="<?php echo get_option('home'); ?>/wp-login.php" method="post" id="login-form">
<p style="color:black!IMPORTANT;">Please login.</p>
<!--[if !(IE)]><!-->
<input type="text" placeholder="Username" name="log" id="log" value="<?php echo wp_specialchars(stripslashes($user_login), 1) ?>" />
<!--<![endif]-->
<!--[if (gte IE 6)]>
<input type="text" name="log" id="log" value="Username" />
<![endif]-->
<!--[if !(IE)]><!-->
<input type="password" placeholder="Password" name="pwd" id="pwd" />
<!--<![endif]-->
<!--[if (gte IE 6)]>
<input type="password" value="Password" name="pwd" id="pwd" />
<![endif]-->
<p style="clear:both;width:115px;font-size:14px!IMPORTANT;float:left;">
<input style="width:14%!IMPORTANT;" name="rememberme" id="rememberme" type="checkbox" checked="checked" value="forever" /> Remember me
</p>
<input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>" />
<p style="float:right;">
<a style="font-size:14px!IMPORTANT;" href="<?php echo get_option('home'); ?>/wp-login.php?action=lostpassword">Recover password</a>
</p>
<input style="margin-left:80px;float:left;" type="submit" name="submit" value="LOGIN" class="login-button" />
</form>
<div class="clear"></div>
<?php } else { ?>
<p>
You are currently logged in, would you like to <a href="<?php echo wp_logout_url($_SERVER['REQUEST_URI']); ?>">logout</a>?
</p>
<?php } ?>
I'm guessing the following...
I need to do something with the username (entered in the form above) then match that with the author of any posts, if that matches then send them to that page... all before the submission of the form above. This needs to be done before the hidden field, so it can enter the username field into the hidden input value.