function xt_update_user_account_cost_counts($user_id, $cash = true, $jifen = true) { if ($cash) { $tixians = xt_total_tixian($user_id); xt_update_user_count($user_id, XT_USER_COUNT_CASH_COST, $tixians[0] + $tixians[1]); } if ($jifen) { $jifenOrder = xt_user_total_jifen_order($user_id); xt_update_user_count($user_id, XT_USER_COUNT_JIFEN_COST, $jifenOrder[0] + $jifenOrder[1]); } }
function xt_update_user_follow($user_id, $f_user_id) { global $wpdb; $fans_count = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM " . XT_TABLE_USER_FOLLOW . " WHERE user_id=%d", $user_id)); xt_update_user_count($user_id, XT_USER_COUNT_FANS, $fans_count); $follows = $wpdb->get_col($wpdb->prepare("SELECT user_id FROM " . XT_TABLE_USER_FOLLOW . " WHERE f_user_id=%d", $f_user_id)); update_user_meta($f_user_id, XT_USER_FOLLOW, $follows); xt_update_user_count($f_user_id, XT_USER_COUNT_FOLLOW, count($follows)); }
function xt_update_user_favorite_count($user_id, $type) { global $wpdb; $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM " . XT_TABLE_FAVORITE . " WHERE user_id = %d AND type=%d", $user_id, $type)); //update user count meta $counts = get_user_meta($user_id, XT_USER_COUNT); $_metakey = _xt_get_favorite_metakey($type); xt_update_user_count($user_id, $_metakey, $count); return $count; }
function xt_update_user_album_count($user_id) { global $wpdb; $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM " . XT_TABLE_ALBUM . " WHERE user_id = %d", $user_id)); //update user option meta xt_update_user_count($user_id, XT_USER_COUNT_ALBUM, $count); return $count; }