Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.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 “如何修复”;trim()需要参数1;类内wp元查询->;选择哪个元键?_Php_Wordpress_Debugging_Woocommerce_Customer - Fatal编程技术网

Php “如何修复”;trim()需要参数1;类内wp元查询->;选择哪个元键?

Php “如何修复”;trim()需要参数1;类内wp元查询->;选择哪个元键?,php,wordpress,debugging,woocommerce,customer,Php,Wordpress,Debugging,Woocommerce,Customer,我正在开发一个外部应用程序,通过我的网站(使用woocommerce)使用注册用户的数据登录该应用程序 我想错误地使用产品到期日(您可以在woocommerce中创建的产品的产品属性)来检查用户是否仍然可以下载产品并因此也可以登录,或者如果不是,则客户不应该能够登录 我对php并没有真正的经验,也没有阅读过wc的文档,但这对我没有帮助 我通过登录从客户那里获得凭据,然后我想使用这些数据来获得订单。从订单上我想看看我是否能得到产品,然后检查产品的有效期是否仍然有效 由于我将元密钥与对象配对,因此元

我正在开发一个外部应用程序,通过我的网站(使用woocommerce)使用注册用户的数据登录该应用程序

我想错误地使用产品到期日(您可以在woocommerce中创建的产品的产品属性)来检查用户是否仍然可以下载产品并因此也可以登录,或者如果不是,则客户不应该能够登录

我对php并没有真正的经验,也没有阅读过wc的文档,但这对我没有帮助

我通过登录从客户那里获得凭据,然后我想使用这些数据来获得订单。从订单上我想看看我是否能得到产品,然后检查产品的有效期是否仍然有效

由于我将元密钥与对象配对,因此元密钥会产生一些问题。错误消息是:

PHP Warning:  trim() expects parameter 1 to be string, object given in
../wp-includes/class-wp-meta-query.php on line 599.
但如果像我在一些解决方案中看到的那样使用
\u customer\u user
,它将不适用于我:

<?php
/*
Template Name: Login
*/
?>

 <?php
    require_once('./wp-includes/pluggable.php');


    $sEmail = $_POST['email'];
    $sPassword = $_POST['password'];
    $sSecret = $_POST['secret'];
    $oUser = get_user_by('email', $sEmail);
    $iUserID = $oUser->ID;
    $sUserName = $oUser->user_login;

    if(!isset($sEmail) || !isset($sPassword) || !isset($sSecret)) {
        die();
    }

    $local_secret = 'XXXXXXXXXXXX';


    // Get the last order by email, orderd by the most recent order and 
    //$args = array(
    //'customer' => $sEmail,
    //'orderby' => 'date',
    //'order' => 'DESC',
    //);
    //$oLastOrder = wc_get_order( $args );
    // Get orders by customer with email 'woocommerce@woocommerce.com'.
    // Get all current customer orders
$customer_orders = wc_get_orders( $args = array(
    'numberposts' => -1,
    'meta_key'    => $oUser,
    'meta_value'  => $iUserID,// for current user id
    'post_status' => array_keys(wc_get_order_statuses()),
) );



// The different loops to get the downloadable products bought by this user
foreach ( $customer_orders as $customer_order )
    if (!empty($customer_orders)){
        foreach ( $customer_orders as $customer_order ){
            if( !$customer_order->has_downloadable_item() && $customer_order->is_paid() ){
                foreach( $customer_order->get_items() as $item ){
                    $item_id = $item[614]; // product ID

                    // Just the downloadable items Below
                    if($item->is_download_permitted()) {

                        //Check Credentials
                        if ($sSecret == $local_secret) {
                            if ($user && wp_check_password( $password, $user->data->user_pass, $user->ID )) {
                                echo json_encode(array("success" => "true"));
                            }else {
                                echo json_encode(array("success" => "false"));
                            }
                        }else {
                            echo json_encode(array("success" => "false"));
                        }
                        //End of Credentialscheck

                    } else {
                        echo json_encode(array("success" => "false"));
                    }
                }
            }
        }
    }

?>

你知道我可以修改什么才能登录吗