【问题标题】:How to pass username into form that sends data to database in wordpress如何将用户名传递给在wordpress中将数据发送到数据库的表单
【发布时间】:2014-10-02 07:29:04
【问题描述】:

我正在尝试通过表单将用户名传递给数据库:

[insert_php]
$current_user= wp_get_current_user();
$id= $current_user->user_login; 
[/insert_php]


<input type="hidden" name="id" value="[insert_php]$id[/insert_php]">

但它没有通过,但其余可见输入确实通过了。

所以我的问题是:

这是正确的结构吗:

$id= ...;

然后在表单中输入:

<input type="hidden" name="id" value="<?php $id; ?>">

应该有效还是我做错了?

【问题讨论】:

    标签: php mysql wordpress forms


    【解决方案1】:

    试试这个:

    global $id;
    

    全局声明它应该是解决方法。

    【讨论】:

    • 我确实有一个表格,它可以正常工作,只有隐藏的值没有通过
    • 你想设置 $id 等于什么?
    • wordpress 中的用户名值,当我在表单前回显 $id 时,它会打印出该值,因此它不为空
    • 我已经在表单前设置了$id,我只需要通过表单传递它,但它不起作用
    • 全局声明变量。看我的回答
    猜你喜欢
    • 1970-01-01
    • 2013-08-09
    • 1970-01-01
    • 2021-10-07
    • 1970-01-01
    • 2017-08-07
    • 1970-01-01
    • 1970-01-01
    • 2014-01-20
    相关资源
    最近更新 更多