Sunday, 2 June 2013

Update user meta on custom wordpress form and redirect

Update user meta on custom wordpress form and redirect

I have a fully functioning custom wordpress form that updates the user meta when they are logged in, however when I submit it just reloads the same page I am on, I am trying to get it to redirect to a thank you page. How would I go about this? Current working code I am using below. Thanks.
    <?php 
        global $current_user;
        get_currentuserinfo();
    if($_POST['gender'] != '') {
    $gender_update = $_POST['gender'];
    update_user_meta($current_user->ID,'gender', $gender_update);
    }
        ?>

<?php
function curURL() {
$pageURL = 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
return $pageURL;
}
?>

<form name="userform" method="post" id="adduser" class="user-forms" action="<?php echo curURL(); ?>"  >

No comments:

Post a Comment