[program-l] PHP problems on wordPress

  • From: Brandon Keith Biggs <brandonkeithbiggs@xxxxxxxxx>
  • To: program-l@xxxxxxxxxxxxx
  • Date: Fri, 17 Apr 2015 21:57:50 +0200

Hello,
I am trying to update user data in wordPress. I have the following function in my functions.php file:

function profile_func($atts){
//set $user as the current logged in user
$user = wp_get_current_user();

//check if there was a submition on this page before with the correct values
if(isset($_POST['submited_user_data']) && wp_verify_nonce($_POST['user_nonce'], 'user-data')){
//The below line is the one that doesn't work and it doesn't even show anything to say the function ran!
echo "The result is: " . update_user_meta($user->ID, 'display_name', $_POST['username']);

//The below line checks the current values and the submitted data.
echo $user->display_name . " Submited " . $_POST['username'] . "!";
}

//Now we load the form that has default values of the current user data.
?>
<form method="post" action="#">
<label for="username">What you would like to be called: </label>
<input id="username" type="text" name="username" value="<?php echo $user->display_name;?>" >
<label for="email">Your email address: </label>
<input id="email" name="email" type="email" value="<?php echo $user->user_email;?>">
<input name="submited_user_data" type="hidden">
<input type="hidden" name="user_nonce" value="<?php echo wp_create_nonce('user-data');?>">
<input type="submit" name="user_update" value="Update your info">
</form>
<?php
}
//This is so I add the short-code [profile] to the body of any post and it will load this.
add_shortcode('profile', 'profile_func');

All the values seem to be correct when I run it, but nothing changes! The function doesn't even return! Does anyone know why?
thanks,

--
Brandon Keith Biggs <http://www.brandonkeithbiggs.com/>

Other related posts: