[program-l] Re: PHP problems on wordPress

  • From: Brandon Keith Biggs <brandonkeithbiggs@xxxxxxxxx>
  • To: program-l@xxxxxxxxxxxxx
  • Date: Sat, 18 Apr 2015 09:37:15 +0200

Hello,
No, wordpress doesn't really offer anything like this to my knowledge. It does have a page for signing up, but it is not how I would like it to look.
Everything runs, but for that one function. All the submited words are the same :).
thanks,

Brandon Keith Biggs <http://www.brandonkeithbiggs.com/>
On 4/17/2015 10:14 PM, Florian Beijers wrote:

Hi,

Two things.
1. What you are trying to implement, doesn't WordPress already offer
this functionality itself? Why reinvent the wheel?
2. In your if-statement, submitted is misspelled. That may have
something to do with it?

Don't really have time to dig into it but those were my two
observations from quickly checking it over.

Florian

2015-04-17 21:57 GMT+02:00, Brandon Keith Biggs <brandonkeithbiggs@xxxxxxxxx>:
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/>

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

Other related posts: