public function save_metadata($post_id)
 {
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     if (Course::POST_TYPE == $_POST['post_type']) {
         #if ( ! current_user_can( 'edit_page', $post_id ) ) return $post_id;
         $fields = Course::addition_fields_list();
         $fields_values = array();
         foreach ($fields as $name => $id) {
             $fields_values[$name] = sanitize_text_field($_POST[$id]);
             $this->updateEntryMeta($post_id, '_' . $name, $fields_values[$name]);
         }
     } elseif (Event::POST_TYPE == $_POST['post_type']) {
         #if ( ! current_user_can( 'edit_post', $post_id ) ) return $post_id;
         $addition_fields = Event::addition_fields_list();
         $fields_values = array();
         // $savan = sanitize_text_field( $_POST[$addition_fields['savan']] );
         // $capitan = sanitize_text_field( $_POST[$addition_fields['capitan']] );
         // $room = sanitize_text_field( $_POST[$addition_fields['room']] );
         // $course = sanitize_text_field( $_POST[$addition_fields['course']] );
         foreach ($addition_fields as $name => $id) {
             if ($name !== 'confirmed') {
                 $fields_values[$name] = sanitize_text_field($_POST[$id]);
                 $this->updateEntryMeta($post_id, '_' . $id, $fields_values[$name]);
             }
         }
     }
 }
Ejemplo n.º 2
0
<?php

use Nerds\Bsalted\Entity\CourseEntity\Course;
use Nerds\Base\Util\Helpers\DatabaseAccessWrapper;
use Nerds\Bsalted\Entity\UserEntity\User;
$db = new DatabaseAccessWrapper();
$savans = User::getByRole('adventure_savant');
$capitans = User::getByRole('adventure_capitan');
$post_id = get_the_ID();
$stored_data = $db->getCourseData()[$post_id];
$fields_list = Course::addition_fields_list();
$human_resourses = explode(',', $stored_data['resourses']);
?>

<div class="bsalted-field">
<label for="<?php 
echo $fields_list['resourses'];
?>
">The Human resources: </label>
<select id="<?php 
echo $fields_list['resourses'];
?>
" data-placeholder="Choose Human resources..." class="chosen-select" multiple style="width:350px;" tabindex="4">
    <optgroup label="Capitans">
    <?php 
foreach ($capitans as $obj) {
    ?>
        <?php 
    if (in_array($obj->ID, $human_resourses)) {
        ?>
            <option value="<?php