Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从WP前端表单保存post_状态(WP用户前端插件)_Php_Wordpress - Fatal编程技术网

Php 从WP前端表单保存post_状态(WP用户前端插件)

Php 从WP前端表单保存post_状态(WP用户前端插件),php,wordpress,Php,Wordpress,试图从前端表单更新post_状态,但无法找出哪里出错。没有以下代码将其保存为“草稿”以用于post_状态。我无法更改select name=“post_status[]”,因为插件会自动生成它 post_状态的前端表单自定义字段 私有的 公开的 Function.php中的函数和插件文档。 //将自定义隐私选项保存到数据库 功能隐私\u发布状态($postarr){ $postarr['post_status']=修剪($_post['post_status[]); 返回$postarr;

试图从前端表单更新post_状态,但无法找出哪里出错。没有以下代码将其保存为“草稿”以用于post_状态。我无法更改select name=“post_status[]”,因为插件会自动生成它

post_状态的前端表单自定义字段


私有的
公开的
Function.php中的函数和插件文档。

//将自定义隐私选项保存到数据库
功能隐私\u发布状态($postarr){
$postarr['post_status']=修剪($_post['post_status[]);
返回$postarr;
}
添加过滤器(“wpuf添加帖子参数”、“隐私帖子状态”);
添加过滤器('wpuf_update_post_args','privacy_post_status');

只是检查一下。。。为什么要使用[]?选择仅接受1值,因此返回值可能是字符串

如果这是一个多选(看起来不像),您可以尝试使用foreach:

foreach ($_POST['post_status'] as $status) {
    $postarr['post_status'] = $status;
}
或者类似的


更新:在foreach上添加了括号。

var_dump of$\u POST['POST_status[]”给您带来了什么?谢谢。它起作用了!由插件生成的Select,它甚至在单个值上都带有[]。它需要括号tho。foreach($\u POST['POST\u status']作为$status){$postarr['POST\u status']=$status;}