I have a custom post type called "conference". I want to create a specific meta key for users who have registered for the conference. For example the meta key slug would be registered_users which stores an array with all ID's of registered users.

Is it possible ? How to create it ? And how to update it when a new user registers? I know how to update a basic meta, but here it's an array... :/

  • If you know how to update a basic meta show us your code and we can help you from there.
    – kraftner
    Feb 19, 2014 at 13:45
  • See Eric's answer. It isn't any different. Feb 19, 2014 at 14:53

1 Answer 1


A postmeta value can be an array. You save it the exact same. Updating/Getting postmeta will detect if the value is an array/object, and serialize the value so it can be stored in the database.

// Saving
$users = array( 5, 20, 25, 29, 30 );
$saved = update_post_meta( get_the_ID(), 'registered_users', $users );

// Getting
$users = get_post_meta( get_the_ID(), 'registered_users', true );
// array( 5, 20, 25, 29, 30 )

Your Answer

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

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