我一直在为我的一个客户开发一个自定义插件,该插件将订单信息输出到Woocommerce的文本文件中。直到最近,一切都很顺利,因为某种无法解释的原因,每次有人登录时,他们的显示名都会从昵称更改为“FirstName LastName”选项。。。。这打断了我的输出。
我需要显示他们的昵称或登录名(相同),而不是显示名称。。。一直到现在都在使用。
以下是我认为是问题的相关部分:
$query = $wpdb->prepare( "SELECT orden.ID AS order_number,
orden.post_modified AS last_date,
orden.post_excerpt AS deliverynotes,
orden.post_modified AS formatteddate,
user.ID AS user_id,
user.user_email AS user_email,
user.display_name AS user_name,
user.user_login AS user_login
FROM {$wpdb->posts} AS orden
LEFT JOIN {$wpdb->postmeta} AS meta
ON (meta.post_id = orden.ID)
LEFT JOIN {$wpdb->users} AS user
ON (user.ID=meta.meta_value )
WHERE
orden.post_type=\'shop_order\'
AND orden.post_status not in (\'trash\', \'auto-draft\')
AND meta.meta_key=\'_customer_user\'
AND orden.ID IN ({$orderIdsArrStr})" , \'\');
$results = $wpdb->get_results($query);
if ( !empty( $results ) ) {
$OrderTXT = \'\';
foreach($results as $result) {
$OrderId=$result->order_number;
$user_email=$result->user_email;
$user_id=$result->user_id;
$user_displayname = $result->user_name;
这是它为我显示订单的部分:
$OrderTXT .= "*,".$user_displayname.",".$OrderId.",".$shippingCustomer[\'client_firstname\']." ".$shippingCustomer[\'client_lastname\'].",".$shippingCustomer[\'$order_company\'].",".$shippingCustomer[\'client_firstname\'].",".$shippingCustomer[\'client_lastname\'].",".$shippingCustomer[\'$order_address1\'].",".$shippingCustomer[\'$order_address2\'].$shippingCustomer[\'$order_address3\'].",".$shippingCustomer[\'$order_city\'].",".$shippingCustomer[\'$order_state\'].",".$shippingCustomer[\'$order_postcode\'].",".$shippingCustomer[\'$order_country\'].",".$shippingCustomer[\'client_phone\'].",,".$user_email.",".$shippingCustomer[\'client_firstname\']." ".$shippingCustomer[\'client_lastname\'].",".$shippingCustomer[\'$order_company\'].",".$shippingCustomer[\'client_firstname\']." ".$shippingCustomer[\'client_lastname\'].",".$shippingCustomer[\'$order_address1\'].",".$shippingCustomer[\'$order_address2\'].$shippingCustomer[\'$order_address3\'].",".$shippingCustomer[\'$order_city\'].",".$shippingCustomer[\'$order_state\'].",".$shippingCustomer[\'$order_postcode\'].",".$shippingCustomer[\'$order_country\'].",".$shippingCustomer[\'client_phone\'].",UPS,00".$OrderId.",Internet,N45,\\n";
正是第一位“$user\\u displayname”改变并显示了错误的内容。如何将其更改为$user\\u昵称??
我已经尝试了$user\\u登录$user\\u昵称。。。。但无济于事。我猜是因为它不在原始查询中?
抱歉问了这么长时间。我相信这是一个非常简单的修复方法。
谢谢