drxm72811 2018-07-19 20:27
浏览 64

在php wordpress插件开发中选择一个默认值

I have dropdown which generates list of countries in wordpress plugin.

By default it selects first country, i want to change it to poland

What should i do?

if( !get_user_meta( get_current_user_id(), 'user_nationality', true ) ) {
    $countries_obj = new WC_Countries();
    $countries = $countries_obj->__get('countries');
    $fields['billing']['user_nationality'] = array(
        'type'      => 'select',
        'label'     => __( 'Nationality', 'mangopay' ),
        'options'   => $countries,
        'required'  => true,

    );
}

it' my own woocomerce related plugin, i am a beginner.

i followed this as well https://codex.wordpress.org/Creating_Options_Pages.

  • 写回答

1条回答 默认 最新

  • douhan6738 2018-07-20 06:04
    关注

    Use "std" => 'default_value', after 'required' => true,

    评论

报告相同问题?

悬赏问题

  • ¥20 关于#qt#的问题:Qt代码的移植问题
  • ¥50 求图像处理的matlab方案
  • ¥50 winform中使用edge的Kiosk模式
  • ¥15 关于#python#的问题:功能监听网页
  • ¥15 怎么让wx群机器人发送音乐
  • ¥15 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化