WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using facebook connect plugin.

Usernames generated by that plugin look like firstname_lastname. I mean it looks ugly.

I would like to give the privilege to my users to change the username BUT ONCE.

I hope its like changing the password.

Here is my change password function.

Can anyone help me to modify it?


share|improve this question
up vote 1 down vote accepted

Just add a meta record that tracks the state of the username-changing actions:

$user = wp_get_current_user();

$did_one_change = get_user_meta($user->ID, 'changed_username', true);

if($did_one_change !== false)
  wp_die('You already changed your user name once!');

  'ID'         => $user->ID, 
  'first_name' => $_POST['first_name'],
  'last_name'  => $_POST['last_name'],

// here add a meta entry that suggests the user has changed their name once
update_user_meta($user->ID, 'changed_username', 1);
share|improve this answer
Hi thanks for your answer , but what will happen if username already exists? – Giri Apr 5 '12 at 19:38
you can check that before doing the update: username_exists() – onetrickpony Apr 5 '12 at 22:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.