小编Kre*_*ion的帖子

可捕获的致命错误:类 WP_User 的对象无法在第 139 行的 /directory/ 中转换为字符串

我目前正在尝试获取提交表单的人的用户名,与他们提交的值一起存储在数据库中。

这是我的函数中的第 139 行:

$retval = $newdb->query("SELECT * FROM $table WHERE user = '$hf_username' ");
Run Code Online (Sandbox Code Playgroud)
add_action("init", "ref_access");
function ref_access() {

global $error;

if ( is_user_logged_in() ) {


    global $quanid;
    global $newdb;
    $hf_username = wp_get_current_user();
    $inputValue  = isset($_POST['$quanid']);
    $newdb = new wpdb( 'user', 'password', 'db', 'localhost' );
    $retval = $newdb->query("SELECT * FROM $table WHERE user = '$hf_username' ");

if( mysqli_num_rows($retval) > 0) 
{
    $newdb->query("UPDATE table SET user = '$hf_username' "); //If user exists, update
}
else
{
global $table;
global $newdb; …
Run Code Online (Sandbox Code Playgroud)

wordpress

3
推荐指数
1
解决办法
6350
查看次数

标签 统计

wordpress ×1