当前位置: 首页>>代码示例>>PHP>>正文


PHP ThemexCore::updateUserMeta方法代码示例

本文整理汇总了PHP中ThemexCore::updateUserMeta方法的典型用法代码示例。如果您正苦于以下问题:PHP ThemexCore::updateUserMeta方法的具体用法?PHP ThemexCore::updateUserMeta怎么用?PHP ThemexCore::updateUserMeta使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ThemexCore的用法示例。


在下文中一共展示了ThemexCore::updateUserMeta方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updateImage

 /**
  * Updates Facebook image
  *
  * @access public
  * @param int $ID
  * @param int $user
  * @return void
  */
 public static function updateImage($ID, $user)
 {
     require_once ABSPATH . 'wp-admin/includes/image.php';
     $attachment = array('ID' => 0);
     $url = 'https://graph.facebook.com/' . intval($ID) . '/picture?type=large';
     $image = @file_get_contents($url);
     if ($image !== false && !empty($image)) {
         $uploads = wp_upload_dir();
         $filename = wp_unique_filename($uploads['path'], 'image-1.jpg');
         $filepath = $uploads['path'] . '/' . $filename;
         $contents = file_put_contents($filepath, $image);
         if ($contents !== false) {
             //upload image
             $attachment = array('guid' => $uploads['url'] . '/' . $filename, 'post_mime_type' => 'image/jpg', 'post_title' => sanitize_title(current(explode('.', $filename))), 'post_content' => '', 'post_status' => 'inherit', 'post_author' => $user);
             //add image
             $attachment['ID'] = wp_insert_attachment($attachment, $attachment['guid'], 0);
             update_post_meta($attachment['ID'], '_wp_attached_file', substr($uploads['subdir'], 1) . '/' . $filename);
             //add thumbnails
             $metadata = wp_generate_attachment_metadata($attachment['ID'], $filepath);
             wp_update_attachment_metadata($attachment['ID'], $metadata);
         }
     }
     //update image
     if (isset($attachment['ID']) && $attachment['ID'] != 0) {
         ThemexCore::updateUserMeta($user, 'avatar', $attachment['ID']);
     }
 }
开发者ID:haythameyd,项目名称:powrly,代码行数:35,代码来源:themex.facebook.php

示例2: updateAdminProfile

 /**
  * Updates admin profile
  *
  * @access public
  * @param mixed $user
  * @return void
  */
 public static function updateAdminProfile($user)
 {
     global $wpdb;
     self::updateProfile($user, $_POST);
     if (current_user_can('edit_users') && isset($_POST['avatar']) && !empty($_POST['avatar'])) {
         $query = "SELECT ID FROM " . $wpdb->posts . " WHERE guid = '" . esc_url($_POST['avatar']) . "'";
         $avatar = $wpdb->get_var($query);
         if (!empty($avatar)) {
             ThemexCore::updateUserMeta($user, 'avatar', $avatar);
         }
     }
 }
开发者ID:rinodung,项目名称:wordpress-demo,代码行数:19,代码来源:themex.user.php

示例3: 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);
         }
     }
 }
开发者ID:qhuit,项目名称:UrbanPekor,代码行数:21,代码来源:themex.woo.php

示例4: activateUser

 /**
  * Activates user
  *
  * @access public
  * @return void
  */
 public static function activateUser()
 {
     if (isset($_GET['activate']) && isset($_GET['user']) && intval($_GET['user']) != 0) {
         $users = get_users(array('meta_key' => '_' . THEMEX_PREFIX . 'activation_key', 'meta_value' => sanitize_text_field($_GET['activate']), 'include' => intval($_GET['user'])));
         if (!empty($users)) {
             $user = reset($users);
             $user = new WP_User($user->ID);
             $user->remove_role('inactive');
             $user->add_role('contributor');
             wp_set_auth_cookie($user->ID, true);
             ThemexCore::updateUserMeta($user->ID, 'activation_key', '');
             wp_redirect(get_author_posts_url($user->ID));
             exit;
         }
     }
 }
开发者ID:qhuit,项目名称:UrbanPekor,代码行数:22,代码来源:themex.user.php

示例5: 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);
 }
开发者ID:TheTypoMaster,项目名称:wp_marketplace,代码行数:68,代码来源:themex.shop.php


注:本文中的ThemexCore::updateUserMeta方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。