Ejemplo n.º 1
0
if (isset($_POST['creditNonce']) && current_user_can('edit_users')) {
    if (!wp_verify_nonce($_POST['creditNonce'], 'credit-nonce')) {
        $message = __('安全认证失败,请重试!', 'um');
    } else {
        $c_user_id = $curauth->ID;
        if (isset($_POST['creditChange']) && sanitize_text_field($_POST['creditChange']) == 'add') {
            $c_do = 'add';
            $c_do_title = __('增加', 'um');
        } else {
            $c_do = 'cut';
            $c_do_title = __('减少', 'um');
        }
        $c_num = intval($_POST['creditNum']);
        $c_desc = sanitize_text_field($_POST['creditDesc']);
        $c_desc = empty($c_desc) ? '' : __('备注', 'um') . ' : ' . $c_desc;
        update_um_credit($c_user_id, $c_num, $c_do, 'um_credit', sprintf(__('%1$s将你的积分%2$s %3$s 分。%4$s', 'um'), $current_user->display_name, $c_do_title, $c_num, $c_desc));
        $message = sprintf(__('操作成功!已将%1$s的积分%2$s %3$s 分。', 'um'), $user_name, $c_do_title, $c_num);
    }
}
//~ 积分end
// 会员start
if (isset($_POST['promoteVipNonce']) && current_user_can('edit_users')) {
    if (!wp_verify_nonce($_POST['promoteVipNonce'], 'promotevip-nonce')) {
        $message = __('安全认证失败,请重试!', 'um');
    } else {
        if (isset($_POST['promotevip_type']) && sanitize_text_field($_POST['promotevip_type']) == '4') {
            $pv_type = 4;
            $pv_type_title = __('终身会员', 'um');
        } elseif (isset($_POST['promotevip_type']) && sanitize_text_field($_POST['promotevip_type']) == '3') {
            $pv_type = 3;
            $pv_type_title = __('年费会员', 'um');
Ejemplo n.º 2
0
function um_like_article()
{
    $pid = $_POST['pid'];
    $likes = get_post_meta($pid, 'um_post_likes', true);
    $likes++;
    update_post_meta($pid, 'um_post_likes', $likes);
    $uid = get_current_user_id();
    $return = 1;
    if ($uid) {
        $meta = get_user_meta($uid, 'um_article_interaction', true);
        $meta = json_decode($meta);
        $now_date = date('Y-m-j');
        $credit = um_get_setting('like_article_credit', 5);
        $times = um_get_setting('like_article_credit_times', 5);
        $get = 0;
        if (!isset($meta->dated) || $now_date != $meta->dated) {
            update_um_credit($uid, $credit, 'add', 'um_credit', sprintf(__('参与文章互动,获得%s积分', 'um'), $credit));
            $new_times = 1;
            $new_meta = json_encode(array('dated' => $now_date, 'times' => $new_times));
            update_user_meta($uid, 'um_article_interaction', $new_meta);
            $get = 1;
        } else {
            if ($meta->times < $times) {
                update_um_credit($uid, $credit, 'add', 'um_credit', sprintf(__('参与文章互动,获得%s积分', 'um'), $credit));
                $new_times = $meta->times;
                $new_times++;
                $new_meta = json_encode(array('dated' => $now_date, 'times' => $new_times));
                update_user_meta($uid, 'um_article_interaction', $new_meta);
                $get = 1;
            } else {
            }
        }
        $return = json_encode(array('get' => $get, 'credit' => $credit));
    }
    echo $return;
    exit;
}
Ejemplo n.º 3
0
function um_daily_sign_callback()
{
    date_default_timezone_set('Asia/Shanghai');
    $msg = '';
    $success = 0;
    $credits = 0;
    if (!is_user_logged_in()) {
        $msg = '请先登录';
    } else {
        $uid = get_current_user_id();
        $date = date('Y-m-d H:i:s', time());
        $sign_date_meta = get_user_meta($uid, 'um_daily_sign', true);
        $sign_date = date('Y-m-d', strtotime($sign_date_meta));
        $now_date = date('Y-m-d', time());
        if ($sign_date != $now_date) {
            update_user_meta($uid, 'um_daily_sign', $date);
            $credits = um_get_setting('daily_sign_credit', 10);
            $credit_msg = '每日签到赠送' . $credits . '积分';
            update_um_credit($uid, $credits, 'add', 'um_credit', $credit_msg);
            $success = 1;
            $msg = '签到成功,获得' . $credits . '积分';
        } else {
            $success = 0;
            $credits = 0;
            $msg = '今日已签到';
        }
    }
    $return = array('msg' => $msg, 'success' => $success, 'credits' => $credits);
    echo json_encode($return);
    exit;
}