最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

advanced custom fields - ACF don't save the selected value

programmeradmin0浏览0评论

firstly i created a select dropdownlist using acf that dynamically populate like this:

add_filter('acf/load_field/name=chef', 'my_acf_load_chef_field');

function my_acf_load_chef_field( $field )
{    
    $user_fields = array( 'user_login');
    $argu = new WP_User_Query( array( 'role' => 'chef' , 'fields' => $user_fields ));
    $choices = $argu->get_results();
    //$choices = get_field($field['choices'], $post->ID , false);
    $field['choices'] = array();  
     if( is_array($choices) ) {
        $len = count($choices);
        for($i = 0; $i < $len; $i++) {
            array_push($field['choices'], ($choices[$i]->user_login));
    }
   }
    return $field;

and it worked well in retrieving data but when i select the wanted chef it save my ACF key instead of the value in post meta value field_5cf49fa0651bb like this

i want to insert the selected value in mysql

发布评论

评论列表(0)

  1. 暂无评论