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,

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?