The answer is, this can't be done with any efficiency. The best thing to do is pull the data out of the serialized array and save each as their own key/value pair in the wp_usermeta
table. My key was extraInfo
and the values I needed were serialized in the value. This is the script I've used to create new keys and values from the data automatically. The echoing was just used for some on screen feedback and isn't necessary. If you have a lot of users, you might want to use number
and offest
in the get_users
query. Hope this helps someone.
<?php
$users = get_users( 'number=10' );
foreach ( $users as $user ) {
$extras = unserialize(get_the_author_meta( "extraInfo", $user->ID ));
foreach ($extras as $key=> $value) {
echo '<p>' . $key . ': ' . $value . '</p>';
update_user_meta( $user->ID, $key, $value);
}
echo '<p>' . esc_html( $user->user_email ) . '</p>';
echo '<hr>';
}
?>