How to store array in usermeta in wordpress

Subtle difference in your name declaration, which needs to be name=”test[]”. <select name=”test[]” id=”test” multiple> <option value=”volvo”>Volvo</option> <option value=”saab”>Saab</option> <option value=”opel”>Opel</option> <option value=”audi”>Audi</option> </select> update_usermeta( $new_user, ‘test’, $_POST[‘test’] ); Edit re: your comment, $meta = get_user_meta($user_id, ‘test’); foreach ($meta as $key => $value) { echo $value; }

User Meta stuff

You have a few PHP issues preventing output- it appears your foreach is commented out with //. you do foreach( $our_children as $children ), but then you use $our_children instead of $children inside the foreach. $children->Age is for accessing an object’s property, but what you have here is an array, so it should be $children[‘Age’] … Read more

custom user meta query

Actually i figured it out now using join SELECT a.ID FROM wp_users a INNER JOIN wp_usermeta b ON b.user_id = a.ID AND ( ( b.meta_key = ‘firstname-groom’ AND b.meta_value LIKE ‘Darren’ ) OR ( b.meta_key = ‘firstname-bride’ AND b.meta_value LIKE ‘Someone’ ) OR ( b.meta_key = ‘lastname-bride’ AND b.meta_value LIKE ‘Cool’ ) ) INNER JOIN … Read more

WP_User_Query not searching

WP_User_Query searches the $wpdb->users table. It will not join on your custom table. How would it know what to JOIN? The possible tables names and structures are practically infinite. I believe you might be able to use a filter on pre_user_query to insert your own values in the WHERE clause but there is no JOIN … Read more

Get users with different roles and call function on each of them (user_meta)

First, always var_dump() something if you aren’t sure what exactly you got. If you ain’t got XDebug installed and configured, just use printf( ‘<pre>%s</pre>’, htmlspecialchars( var_export( $dumpMe, true ) ) ); which will bring up an equally informative response. About the WP_User_Query) IIRC it returns objects which are instances of WP_User. You can test that … Read more