function userpro_edit_restrict() { global $post; echo '<div class="misc-pub-section misc-pub-section-last misc-pub-userpro" style="border-top: 1px solid #eee;">'; wp_nonce_field(plugin_basename(__FILE__), 'userpro_edit_restrict_nonce'); $val = get_post_meta($post->ID, '_userpro_edit_restrict', true) ? get_post_meta($post->ID, '_userpro_edit_restrict', true) : 'none'; echo '<input type="radio" name="userpro_edit_restrict" id="userpro_edit_restrict-none" value="none" ' . checked($val, 'none', false) . ' /> <label for="userpro_edit_restrict-none" class="select-it">' . __('No restriction', 'userpro') . '</label><br />'; echo '<input type="radio" name="userpro_edit_restrict" id="userpro_edit_restrict-true" value="true" ' . checked($val, 'true', false) . '/> <label for="userpro_edit_restrict-true" class="select-it">' . __('Restricted to All Members', 'userpro') . '</label><br />'; echo '<input type="radio" name="userpro_edit_restrict" id="userpro_edit_restrict-verified" value="verified" ' . checked($val, 'verified', false) . '/> <label for="userpro_edit_restrict-verified" class="select-it">' . __('Restricted to <b>Verified Accounts</b>', 'userpro') . '</label><br />'; echo '<input type="radio" name="userpro_edit_restrict" id="userpro_edit_restrict-roles" value="roles" ' . checked($val, 'roles', false) . '/> <label for="userpro_edit_restrict-roles" class="select-it">' . __('Restricted to <b>User Roles</b>', 'userpro') . '</label>'; ?> <p class="restrict_roles"><select name="restrict_roles[]" id="restrict_roles[]" multiple="multiple" class="chosen-select" style="width:300px" data-placeholder="<?php _e('Select roles', 'userpro'); ?> "> <?php if (!isset($wp_roles)) { $wp_roles = new WP_Roles(); } $roles = $wp_roles->get_names(); foreach ($roles as $k => $v) { ?> <option value="<?php echo $k; ?> " <?php userpro_is_selected($k, get_post_meta($post->ID, 'restrict_roles', true)); ?> ><?php echo $v; ?> </option> <?php } ?> </select></p> <?php echo '</div>'; }
<select name="allowed_roles[]" id="allowed_roles[]" multiple="multiple" class="chosen-select" style="width:300px" data-placeholder="<?php _e('Select roles', 'userpro'); ?> "> <?php if (!isset($wp_roles)) { $wp_roles = new WP_Roles(); } $roles = $wp_roles->get_names(); foreach ($roles as $k => $v) { ?> <option value="<?php echo $k; ?> " <?php userpro_is_selected($k, userpro_get_option('allowed_roles')); ?> ><?php echo $v; ?> </option> <?php } ?> </select> <span class="description"><?php _e('If you enable users to select their role, this option can limit allowed roles for user.', 'userpro'); ?> </span> </td> </tr>