Add and retrieve associative array from user meta
-
Hi,
I am working on building a community portal out of WordPress. I have about 50 meta fields to be added to a user’s profile once they register on the site. These meta fields would be overwritten with new values whenever the user makes changes to his/her profile.
Obviously, it’s a task to be handled by add_user_meta and update_user_meta functions. Since, these functions involve interactions with the database, I am worried whether large number of calls to add_user_meta or update_user_meta could bring the database to it’s knees?
My thought on this, has led me to think of an alternative of storing the meta fields and associated values into an array and then with a single call to add_user_meta or update_user_meta, store the array to the database.
e.g:$user_profile_settings = array( 'profile_photo' => 'xyz.png', 'language' => 'english', 'birthday' => '11-11-80', 'gender' => 'male', 'city' => 'NY', 'state' => '', 'country' => 'United States', ); add_user_meta($userID, 'user_profile_settings', $user_profile_settings, true);
This can substantially bring down the number of calls to the said functions. Should I go with this alternative or am I unnecessarily worried about the number of calls to add_user_meta and update_user_meta? Please, note that I am talking of this keeping in mind the “extremely large” user base.
Regards,
John
- The topic ‘Add and retrieve associative array from user meta’ is closed to new replies.