Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Update user profile via form on page WordPress

  • SOLVED

Hi guys,

I'm trying to create a form where users can update their ZIP code.

I'm using Wishlists plugin for users to register, after doing it, they are redirected to a "Thank you" page. I'd like to insert a form on that page which updates the user's profile (WP already knows that he's registered and who he is) on WP backend.

Any idea how?

I tried using Register Plus but it's not updated to be used with current WP version plus dunno how to use it really..

Thanks!

J

/* Update: 10.50am */

Thanks for your answers guys!
Mingle won't work as it requires me to create extra pages for 'activity', 'friends', etc.

Cimy: looks interesting but it won't accomplish what I'm looking for as that Reg page (thanks a mil for creating a sample one!) is WP's default, and I'd like users to simply update their profile by inserting the zip code in a form on that "Thank You" page...

Answers (2)

2010-02-17

Erez S answers:

you can to install mingle and to create only the profile update page


Erez S comments:

did you tried theme-my-login?


Erez S comments:

and check this out tipsforwordpress.com/wordpress/add-custom-field-to-register-form/


Erez S comments:

and here is an article that explain how to edit the user metadata justintadlock.com/archives/2009/09/10/adding-and-using-custom-user-profile-fields


Erez S comments:

and last article blog.ftwr.co.uk/archives/2009/07/19/adding-extra-user-meta-fields/


chocks comments:

Thanks erez213 for your posts, but they are about adding a custom field on the profile page and that's not what I need.. I 'simply' want a form on the front-end of a regular page to update the User's profile (currently logged in): this field is already in the profile: "Zip".


Erez S comments:

add the following code to your functions.php:
function add_form($content) {
global $current_user;
$page_name = 'thanks-you';
$key = 'user_email';
$success = 'The zip Code chagnged...bla bla.';
if(is_page($page_name) && is_user_logged_in()){
get_currentuserinfo();
$user_info = get_userdata($current_user->ID);

if(isset($_POST['zip'])){
update_usermeta( $current_user->ID, $key, $_POST['zip'] );
$content .= $success
} else{
$zip = $user_info->$key;
$content .= '<form method="post"><input type="text" name="zip" value="'.$zip.'" /><input type="submit" value="Update" /></form>';
}
}
return $content;
}
add_filter('the_content', 'add_form');

chane the value of the following variables:
$page_name to the name of the page where you want to show the form
$key to the name of the zip in the wordpress admin panel
$success to the text that you want to show on success


Erez S comments:

my bad,i had a little syntax problem:
function pypy_add_form($content) {
global $current_user;
$page_name = 'thanks-you';
$key = 'user_email';
$success = 'The zip Code chagnged...bla bla.';
if(is_page($page_name) && is_user_logged_in()){
get_currentuserinfo();
$user_info = get_userdata($current_user->ID);
if(isset($_POST['zip'])){
update_usermeta( $current_user->ID, $key, $_POST['zip'] );
$content .= $success;
} else{
$zip = $user_info->$key;
$content .= '<form method="post"><input type="text" name="zip" value="'.$zip.'" /><input type="submit" value="Update" /></form>';
}
}
return $content;
}
add_filter('the_content', 'pypy_add_form');

2010-02-17

Sidd answers:

Simply install Cimy User Extra Fields. It will allow you to add a custom field. The field will be available when they register. Once registered, they can log in and go to their profile to change the particular field.
You may introduce the ZIPCODE field and have users fill it up when they register. Later on, they may log in and edit the value for ZIPCODE as they please .

You may want to see this http://bit.ly/bsYzhY

This is a different approach and indirectly answers the problem, but I guess it does solve the problem.

: ) Sidd.


Sidd comments:

You may wanna see the demo page again. It's WP default now with just the extra ZIPCODE field.

:)