I've been putting together an advanced post notification system for wordpress custom posts, based on Carlo Daniele's post here: http://www.smashingmagazine.com/2015/05/building-wordpress-notification-system/
I'm trying to modify it so that user can select multiple States/Areas, where I'm running into trouble is posting the selected states to the database.
$smashing_notification_states = array( '- Dublin City Centre -' => '- Dublin City Centre -', '- North Dublin City -' => '- North Dublin City -',
'- South Dublin City -' => '- South Dublin City -',
'- North Co. Dublin -' => '- North Co. Dublin -',
'- South Co. Dublin -' => '- South Co. Dublin -',
'- West Co. Dublin -' => '- West Co. Dublin -', );
Select Area: `
<td>
<label for="state">
<select multiple="multiple" name="state">
<option value="" <?php selected( get_user_meta( $user->ID, 'state', true ), "" ); ?>>Select</option>
<?php foreach ($smashing_notification_states as $key => $value) { ?>
<option value="<?php echo $key; ?>" <?php selected( esc_attr( get_user_meta( $user->ID, 'state', true ) ), $key ); ?>><?php echo $value; ?></option>
<?php } ?>
</select>
<?php _e( 'Select area', 'smashing' ); ?>
</label>
</td>
</tr>`
if( isset($_POST['state']) )
update_user_meta( $user_id, 'state', sanitize_text_field( $_POST['state'] ) );
I've pushed and pulled at it but to no avail, tried. Last thing I tried was changing <select multiple="multiple" name="state">
to <select multiple="multiple" name="state[]">
This posted as "Array"
Any help would be great as always!