我被卡住了,而wp-courseware
的插件版主并不愿意为此提供帮助。
我正在尝试抓取wordpress用户数据(电子邮件和国家/地区),然后将其放入一个将动态发送此数据的文件中。
我正在使用wp-courseware,我发现了以下代码并尝试集成用户详细信息(主要是国家/地区代码)
function WPCW_actions_users_moduleCompleted($userID, $unitID,
$unitParentData)
{
if (!$userID || !$unitID || !$unitParentData) {
return;
}
$userDetails = get_userdata($userID);
// Admin wants an email notification, and email address exists. Assumption
is that it's valid.
if ($unitParentData->email_complete_module_option_admin == 'send_email' &&
$unitParentData->course_to_email)
{
$adminSubject = __("Module Complete Notification - {USER_NAME} - Module
{MODULE_NUMBER}", 'wp_courseware');
$adminBody = __("Hi Trainer!
Just to let you know, {USER_NAME} has just completed 'Module {MODULE_NUMBER} - {MODULE_TITLE}'.
{SITE_NAME}
{SITE_URL}
", 'wp_courseware');
// Do email sending now
WPCW_email_sendEmail($unitParentData,
$userDetails, // User who's done the completion
$unitParentData->course_to_email,
$adminSubject, $adminBody);
}
// Check if admin wants user to have an email.
if ($unitParentData->email_complete_module_option == 'send_email')
{
WPCW_email_sendEmail($unitParentData,
$userDetails, // User who's done the completion
$userDetails->user_email,
$unitParentData->email_complete_module_subject, // Use subject template in the settings
$unitParentData->email_complete_module_body // Use body template in the settings
);
}
// Any additional admin-level notifications?
do_action("wpcw_user_completed_module_notification", $unitParentData,
$userDetails, $adminSubject, $adminBody);
}
答案 0 :(得分:0)
这取决于您或您正在使用的插件如何将Country数据保存到数据库。查看wp_usermeta表并查找保存国家/地区的密钥。或者,由于上面的函数已经使用$userDetails = get_userdata($userID);
抓取了所有用户的元数据,因此您可以打印$userDetails
数组并查看您必须使用的内容。
请注意使用$userDetails->user_email;
抓取电子邮件的方式。它将与此类似,使用该国家meta_key。