rAthus icon

[WordPress] EventON custom fields hack in functions.php

rAthus | PRO | 03/07/19 02:43:56 PM UTC | 0 ⭐ | 572 👁️ | Never ⏰ | []
PHP |

970 B

|

None

|

0 👍

/

0 👎

/** EventON custom fields **/
add_filter('evocsv_additional_csv_fields', 'evocsv_function1', 10, 1);
function evocsv_function1($array) {
    $array['discipline'] = 'discipline';
    $array['departement'] = 'departement';
    $array['site_internet'] = 'site_internet';
    $array['formation'] = 'formation';
    return $array;
}
add_action('evocsv_save_event_custom_data', 'evocsv_function2', 10, 3);
function evocsv_function2($eventID, $postdata, $field) {
    if ($field=='discipline' and isset($postdata[$field])) {
        add_post_meta($eventID, '_evcal_ec_f2a1_cus', $postdata[$field]);
    }
    elseif ($field=='departement' and isset($postdata[$field])) {
        add_post_meta($eventID, '_evcal_ec_f1a1_cus', $postdata[$field]);
    }
    elseif ($field=='site_internet' and isset($postdata[$field])) {
        add_post_meta($eventID, '_evcal_ec_f3a1_cus', $postdata[$field]);
    }
    elseif ($field=='formation' and isset($postdata[$field])) {
        add_post_meta($eventID, '_evcal_ec_f4a1_cus', $postdata[$field]);
    }
}

Comments