本文整理汇总了PHP中ThemexCore::getUserMeta方法的典型用法代码示例。如果您正苦于以下问题:PHP ThemexCore::getUserMeta方法的具体用法?PHP ThemexCore::getUserMeta怎么用?PHP ThemexCore::getUserMeta使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ThemexCore
的用法示例。
在下文中一共展示了ThemexCore::getUserMeta方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateAvatar
/**
* Updates user avatar
*
* @access public
* @param int $ID
* @param array $file
* @return void
*/
public static function updateAvatar($ID, $file)
{
wp_delete_attachment(ThemexCore::getUserMeta($ID, 'avatar'));
$attachment = ThemexCore::uploadImage($file);
if (isset($attachment['ID']) && $attachment['ID'] != 0) {
ThemexCore::updateUserMeta($ID, 'avatar', $attachment['ID']);
}
}
示例2: getSettings
/**
* Gets user settings
*
* @access public
* @param int $ID
* @return array
*/
public static function getSettings($ID)
{
$settings['notices'] = ThemexCore::getUserMeta($ID, 'notices', '1');
return $settings;
}
示例3: updateBalance
/**
* Updates shop balance
*
* @access public
* @param int $user
* @param array $data
* @return void
*/
public static function updateBalance($user, $data = array())
{
$shop = ThemexUser::getShop($user);
//values
$revenue = 0;
$profit = 0;
$balance = 0;
$sales = 0;
//rates
$rate_min = absint(ThemexCore::getOption('shop_rate_min', 50));
$rate_max = absint(ThemexCore::getOption('shop_rate_max', 70));
$rate_amount = absint(ThemexCore::getOption('shop_rate_amount', 1000));
if (isset($data['order'])) {
$rate = $rate_min;
if ($rate_max > $rate_min) {
$rate = absint(ThemexCore::getUserMeta($user, 'rate', $rate_min));
}
$rate = self::filterRate($shop, $rate);
ThemexCore::updatePostMeta($data['order'], 'rate', $rate);
}
//orders
$orders = ThemexWoo::getOrders($user, array('post_status' => 'wc-completed'));
foreach ($orders as $order) {
$object = wc_get_order($order);
$rate = absint(ThemexCore::getPostMeta($order, 'rate', $rate_min));
$total = $object->get_total() - $object->get_total_refunded();
$amount = $total * $rate / 100;
$revenue = $revenue + $total;
$profit = $profit + $amount;
if ($object->payment_method != 'paypal-adaptive-payments') {
$balance = $balance + $amount;
}
$sales = $sales + $object->get_item_count();
}
//referrals
$rate = absint(ThemexCore::getOption('shop_rate_referral', '30'));
$referrals = ThemexWoo::getReferrals($user, array('post_status' => 'wc-completed'));
foreach ($referrals as $referral) {
$object = wc_get_order($referral);
$total = $object->get_total() - $object->get_total_refunded();
$amount = $total * $rate / 100;
$profit = $profit + $amount;
$balance = $balance + $amount;
}
//withdrawals
$withdrawals = self::getWithdrawals($user, array('post_status' => array('pending', 'publish')));
foreach ($withdrawals as $withdrawal) {
$amount = abs(floatval(ThemexCore::getPostMeta($withdrawal, 'amount')));
$balance = $balance - $amount;
}
//rate
if ($rate_max > $rate_min) {
$rate = absint($rate_min + $revenue / ($rate_amount / ($rate_max - $rate_min)));
ThemexCore::updateUserMeta($user, 'rate', $rate);
}
ThemexCore::updateUserMeta($user, 'revenue', $revenue);
ThemexCore::updateUserMeta($user, 'profit', $profit);
ThemexCore::updateUserMeta($user, 'balance', $balance);
ThemexCore::updatePostMeta($shop, 'sales', $sales);
}
示例4: setAffiliate
/**
* Sets affiliate
*
* @access public
* @param string $login
* @return void
*/
public static function setAffiliate($login)
{
$login = sanitize_user($login);
if (!empty($login) && !ThemexCore::checkOption('shop_referrals')) {
$user = get_user_by('login', $login);
$affiliate = intval(themex_value(THEMEX_PREFIX . 'affiliate', $_COOKIE));
if ($user !== false && (empty($affiliate) || $user->ID != $affiliate)) {
$expire = time() + 86400 * 10;
setcookie(THEMEX_PREFIX . 'affiliate', $user->ID, $expire, COOKIEPATH, COOKIE_DOMAIN, false);
$clicks = intval(ThemexCore::getUserMeta($user->ID, 'clicks'));
ThemexCore::updateUserMeta($user->ID, 'clicks', $clicks + 1);
}
}
}
示例5: isMember
/**
* Checks user membership
*
* @access public
* @param int $ID
* @return bool
*/
public static function isMember($ID)
{
if (ThemexCore::checkOption('membership_free')) {
$hidden = intval(ThemexCore::getUserMeta($ID, 'hidden'));
if ($hidden == 1) {
return false;
}
}
return true;
}