示例#1
0
function aitApproveClaim($claimId)
{
    global $claimMessages, $aitThemeOptions;
    $username = get_post_meta($claimId, 'username', true);
    $email = get_post_meta($claimId, 'email', true);
    $itemId = intval(get_post_meta($claimId, 'item_id', true));
    // register
    $userId = aitRegisterDirectoryUser($username, $email);
    if (is_wp_error($userId)) {
        $claimMessages = $userId->get_error_message();
    } else {
        // set role
        $role = isset($aitThemeOptions->directory->claimListingRole) ? $aitThemeOptions->directory->claimListingRole : "directory_1";
        $user = get_userdata($userId);
        $user->set_role($role);
        // write activation time
        aitDirWriteActivationTime($userId, $role);
        // change item author
        $item = get_post($itemId, 'ARRAY_A');
        $itemUpdated = $item;
        $itemUpdated['post_author'] = $userId;
        $chStatus = wp_insert_post($itemUpdated, true);
        if (is_wp_error($chStatus)) {
            $claimMessages = $chStatus->get_error_message();
        } else {
            // change status
            update_post_meta($claimId, 'status', 'approved');
            // show message
            $claimMessages = __('Claim was approved! New user was registered and assignated to Item. Email with generated password was sent.', 'ait');
        }
    }
}
示例#2
0
                        $registerMessages = __('PayPal recurring payments profile created. Your directory account was upgraded!', 'ait');
                    } else {
                        $registerMessages = __('PayPal recurring payments profile created. Your directory account was activated! Check your email address for password!', 'ait');
                    }
                }
            } else {
                //  Single payment
                $params = array('TOKEN' => $checkoutDetails['TOKEN'], 'PAYERID' => $checkoutDetails['PAYERID'], 'PAYMENTACTION' => 'Sale', 'PAYMENTREQUEST_0_AMT' => $checkoutDetails['PAYMENTREQUEST_0_AMT'], 'PAYMENTREQUEST_0_CURRENCYCODE' => $checkoutDetails['CURRENCYCODE']);
                $singlePayment = $paypal->request('DoExpressCheckoutPayment', $params);
                // IF PAYMENT OK
                if (is_array($singlePayment) && $singlePayment['ACK'] == 'Success') {
                    // set role
                    $user = new WP_User($userId);
                    $user->set_role($role);
                    // write activation time
                    aitDirWriteActivationTime($userId, $role);
                    // We'll fetch the transaction ID for internal bookkeeping
                    $transactionId = $singlePayment['PAYMENTINFO_0_TRANSACTIONID'];
                    update_user_meta($userId, 'dir_paypal_transaction_id', $transactionId);
                    // show messages
                    if (isset($_GET['upgrade'])) {
                        $registerMessages = __('Your directory account was upgraded!', 'ait');
                    } else {
                        $registerMessages = __('Your directory account was activated! Check your email address for password!', 'ait');
                    }
                }
            }
        }
    }
}
// delete token and show messages if user cancel payment