Help with wp_dropdown_categories – Pre Selected Values in Multi-Select
-
I have been staring at the following block of code for while now and could use a little help. It is part of of a modified user profile. When the user is editing the values via a form the multi-select form element should be pre-populated with the values contained with in the user’s profile. I just can’t seem to get the selected=”selected” attribute added to those options. Any help would be greatly appreciated!!
job_ind_pref_call = custom user field
<?php $sel = 0; $sel1 = get_user_meta($user_ID, 'job_ind_pref_call', true); if(isset($_POST['job_ind_pref_call'])) { $sel1 = $_POST['job_ind_pref_call']; } if (isset($posted['job_term_cat']) && $posted['job_term_cat']>0) $sel = $posted['job_term_cat']; global $featured_job_cat_id; $args = array( 'orderby' => 'name', 'exclude' => 3, 'order' => 'ASC', 'name' => 'job_ind_pref_call[]', 'hierarchical' => 1, 'echo' => 0, 'class' => 'job_cat', 'selected' => $sel1, 'taxonomy' => 'job_cat', 'hide_empty' => false ); $dropdown = wp_dropdown_categories( $args ); $dropdown = str_replace('class=\'job_cat\' >','class=\'job_cat\' multiple="multiple" size="6" onClick=GetMDDselections("job_ind_pref_call") ><option value="">'.__('Select a Line…', 'colabsthemes').'</option>'); echo $dropdown; ?></p>
- The topic ‘Help with wp_dropdown_categories – Pre Selected Values in Multi-Select’ is closed to new replies.