0

I have a user registration form in the front end (in the Users admin section as well) with three extra fields (apart from default ones): birthday, country, language. their values are stored in usermeta table.

I have this action hook to retireve all meta data for the registered user:

add_action('user_register', 'new_user_func');
// user registration callback function
function new_user_func($userID) {
 $newUser = get_user_meta( $userID );
 $userMeta = array();
 foreach ($newUser as $key => $value) {
 $userMeta[$key] = $value[0];
 }
 //do something with $userMeta...
}

var_dump($userMeta) after submit doesn't give me the extra fields value though.. only defaults (first name, last name etc)

Anyone know what might be the case?

asked Aug 3, 2012 at 10:07

2 Answers 2

0

Did you try getting the values with:

$meta = get_the_author_meta($meta_key, $user_id);

Perhaps the meta values you add yourself isn't supported by get_user_meta() .

If this don't work either, perhaps you need to look on how you went about creating the new meta fields. Theres a pretty decent tutorial on how to do it here: http://justintadlock.com/archives/2009/09/10/adding-and-using-custom-user-profile-fields

answered Aug 3, 2012 at 10:19
Sign up to request clarification or add additional context in comments.

2 Comments

get_the_author_meta($meta_key, $user_id) returns a an empty string :/
i have another hook for profile update so when i edit a user in dashboard it retrieves the extra meta values. i am using ProfileBuilder Pro to add those extra fields.
0

Read de Codex entry for user_register action, it says: Not all user metadata has been stored in the database when this action is triggered.

answered Oct 13, 2020 at 11:50

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.