我正在使用高级自定义字段插件,我有一个名为“course”的自定义帖子类型,其中一些来自ACF的字段与之相关。
我有以下代码:
function update_course($course_id) {
//Check conditions and tell user if certain values are incorrect/inconsitence
$nr_available = intval(get_field(\'nr_available\'));
$nr_registered = intval(get_field(\'nr_registered\'));
echo \'nr avail=\' . $nr_available;
echo \'nr registered=\' . $nr_registered;
}
add_action( \'edit_post\' , \'update_course\');
我想做的事情是检查可用点是否少于,然后注册=不正确。然后我想指出用户做得不正确。
但无论如何,我真正的问题是,我不知道如何(我不知道)从发布的自定义帖子类型的ACF中获取值(当然)。
上面只会返回数据库中的实际值(我认为对于当前课程),I want the posted values. 如果我查看$\\u POST变量,它会显示如下内容:
[field_524bceba787b8] => 800 [field_524bcf0a787b9] => 40 [field_524bcf58787ba] => 50 [field_524bcfdb787bb] => [field_524bd005787bc] => [field_5253d4b31053b] => 0
UPDATE:整个阵列看起来像:
Array ( [_wpnonce] => 8fce853ce2 [_wp_http_referer] => /wp-admin/post.php?post=1911&action=edit&message=1 [user_ID] => 1 [action] => editpost [originalaction] => editpost [post_author] => 1 [post_type] => course [original_post_status] => publish [referredby] => http://{host}/wp-admin/post.php?post=1911&action=edit&message=1 [_wp_original_http_referer] => http://{host}/wp-admin/post.php?post=1911&action=edit&message=1 [post_ID] => 1911 [autosavenonce] => 0995694d61 [meta-box-order-nonce] => 1da8897fe1 [closedpostboxesnonce] => c92ea6dd81 [post_title] => Balett 8-9 år [samplepermalinknonce] => 31966e47cc [content] => coolt222 [wp-preview] => [hidden_post_status] => publish [post_status] => publish [hidden_post_password] => [hidden_post_visibility] => public [visibility] => public [post_password] => [mm] => 10 [jj] => 02 [aa] => 2013 [hh] => 07 [mn] => 52 [ss] => 46 [hidden_mm] => 10 [cur_mm] => 10 [hidden_jj] => 02 [cur_jj] => 08 [hidden_aa] => 2013 [cur_aa] => 2013 [hidden_hh] => 07 [cur_hh] => 20 [hidden_mn] => 52 [cur_mn] => 55 [original_publish] => Uppdatera [save] => Uppdatera [tax_input] => Array ( [categorycourses] => Array ( [0] => 0 [1] => 29 [2] => 27 ) ) [newcategorycourses] => Namn för ny kategori [newcategorycourses_parent] => -1 [_ajax_nonce-add-categorycourses] => 2a26873ebd [acf_nonce] => 52e8f939a6 [fields] => Array ( [field_524bcd27ed097] => [field_524bcde2787b4] => o [field_524bce12787b5] => 433 [field_524bce5f787b6] => 1/:00 [field_524bce98787b7] => [field_524bceba787b8] => 1000 [field_524bcf0a787b9] => 10000 [field_524bcf58787ba] => 5 [field_524bcfdb787bb] => [field_524bd005787bc] => [field_5253d4b31053b] => 0 ) [advanced_view] => 1 [add_comment_nonce] => 82940723b5 [_ajax_fetch_list_nonce] => 83bc001ed1 [post_name] => balett-8-9-ar [post_author_override] => 1 [post_mime_type] => [ID] => 1911 [post_content] => coolt222 [comment_status] => closed [ping_status] => closed )