本文整理汇总了PHP中pmpro_getMembershipLevelForUser函数的典型用法代码示例。如果您正苦于以下问题:PHP pmpro_getMembershipLevelForUser函数的具体用法?PHP pmpro_getMembershipLevelForUser怎么用?PHP pmpro_getMembershipLevelForUser使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pmpro_getMembershipLevelForUser函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pmpro_upgrade_1_8_9_3_ajax
function pmpro_upgrade_1_8_9_3_ajax()
{
global $wpdb;
$debug = false;
$run = true;
//some vars
$all_levels = pmpro_getAllLevels(true, true);
//keeping track of which user we're working on
$last_user_id = get_option('pmpro_upgrade_1_8_9_3_last_user_id', 0);
//get all active users during the period where things may have been broken
$user_ids = $wpdb->get_col("SELECT user_id FROM {$wpdb->pmpro_memberships_users} WHERE status = 'active' AND modified > '2016-05-19' AND user_id > {$last_user_id} ORDER BY user_id LIMIT 10");
//track progress
$first_load = get_transient('pmpro_updates_first_load');
if ($first_load) {
$total_users = $wpdb->get_var("SELECT COUNT(user_id) FROM {$wpdb->pmpro_memberships_users} WHERE status = 'active' AND modified > '2016-05-19' ORDER BY user_id");
update_option('pmpro_upgrade_1_8_9_3_total', $total_users, 'no');
$progress = 0;
} else {
$total_users = get_option('pmpro_upgrade_1_8_9_3_total', 0);
$progress = get_option('pmpro_upgrade_1_8_9_3_progress', 0);
}
update_option('pmpro_upgrade_1_8_9_3_progress', $progress + count($user_ids), 'no');
global $pmpro_updates_progress;
if ($total_users > 0) {
$pmpro_updates_progress = "[" . $progress . "/" . $total_users . "]";
} else {
$pmpro_updates_progress = "";
}
if (empty($user_ids)) {
//done with this update
pmpro_removeUpdate('pmpro_upgrade_1_8_9_3_ajax');
delete_option('pmpro_upgrade_1_8_9_3_last_user_id');
delete_option('pmpro_upgrade_1_8_9_3_total');
delete_option('pmpro_upgrade_1_8_9_3_progress');
} else {
foreach ($user_ids as $user_id) {
$last_user_id = $user_id;
//keeping track of the last user we processed
$user = get_userdata($user_id);
//user not found for some reason
if (empty($user)) {
if ($debug) {
echo "User #" . $user_id . " not found.\n";
}
continue;
}
//get level
$user->membership_level = pmpro_getMembershipLevelForUser($user->ID);
//has a start and end date already
if (!empty($user->membership_level->enddate) && !empty($user->membership_level->startdate)) {
if ($debug) {
echo "User #" . $user_id . ", " . $user->user_email . " already has a start and end date.\n";
}
continue;
}
//get order
$last_order = new MemberOrder();
$last_order->getLastMemberOrder();
/*
Figure out if this user should have been given an end date.
The level my have an end date.
They might have used a discount code.
They might be using the set-expiration-dates code.
They might have custom code setting the end date.
Let's setup some vars as if we are at checkout.
Then pass recreate the level with the pmpro_checkout_level filter.
And use the end date there if there is one.
*/
global $pmpro_level, $discount_code, $discount_code_id;
//level
$level_id = $user->membership_level->id;
$_REQUEST['level'] = $level_id;
//gateway
if (!empty($last_order) && !empty($last_order->gateway)) {
$_REQUEST['gateway'] = $last_order->gateway;
} else {
$_REQUEST['gateway'] = pmpro_getGateway();
}
//discount code
$discount_code_id = $user->membership_level->code_id;
$discount_code = $wpdb->get_var("SELECT code FROM {$wpdb->pmpro_discount_codes} WHERE id = '" . $discount_code_id . "' LIMIT 1");
//get level
if (!empty($discount_code_id)) {
$sqlQuery = "SELECT l.id, cl.*, l.name, l.description, l.allow_signups FROM {$wpdb->pmpro_discount_codes_levels} cl LEFT JOIN {$wpdb->pmpro_membership_levels} l ON cl.level_id = l.id LEFT JOIN {$wpdb->pmpro_discount_codes} dc ON dc.id = cl.code_id WHERE dc.code = '" . $discount_code . "' AND cl.level_id = '" . (int) $level_id . "' LIMIT 1";
$pmpro_level = $wpdb->get_row($sqlQuery);
//if the discount code doesn't adjust the level, let's just get the straight level
if (empty($pmpro_level)) {
$pmpro_level = $all_levels[$level_id];
}
//filter adjustments to the level
$pmpro_level->code_id = $discount_code_id;
$pmpro_level = apply_filters("pmpro_discount_code_level", $pmpro_level, $discount_code_id);
}
//no level yet, use default
if (empty($pmpro_level)) {
$pmpro_level = $all_levels[$level_id];
}
//no level for some reason
if (empty($pmpro_level) && empty($pmpro_level->id)) {
//.........这里部分代码省略.........
示例2: pmpro_slack_pmpro_after_checkout
/**
* Main Slack Integration Function
*
* @param $user_id
*
* @since 1.0
*/
function pmpro_slack_pmpro_after_checkout($user_id)
{
$level = pmpro_getMembershipLevelForUser($user_id);
$current_user = get_userdata($user_id);
$options = get_option('pmpro_slack');
$webhook_url = $options['webhook'];
$levels = $options['levels'];
// Only if this level is in the array.
if (!in_array($level->id, $levels)) {
return;
}
// Check that webhook exists in the settings page
if ($webhook_url !== "") {
if (is_user_logged_in()) {
$payload = array('text' => 'New checkout: ' . $current_user->user_email, 'username' => 'PMProBot', 'icon_emoji' => ':credit_card:', 'attachments' => array('fields' => array('color' => '#8FB052', 'title' => $current_user->display_name . ' has checked out for ' . $level->name . ' ($' . $level->initial_payment . ')')));
$output = 'payload=' . json_encode($payload);
$response = wp_remote_post($webhook_url, array('body' => $output));
if (is_wp_error($response)) {
$error_message = $response->get_error_message();
echo "Something went wrong: {$error_message}";
}
}
/**
* Runs after the data is sent.
*
* @param array $response Response from server.
*
* @since 0.3.0
*/
do_action('pmpro_slack_sent', $response);
}
}
示例3: pmpro_ipnhandler_level_extend_memberships
function pmpro_ipnhandler_level_extend_memberships($level, $user_id)
{
global $pmpro_msg, $pmpro_msgt;
//does this level expire? are they an existing user of this level?
if (!empty($level) && !empty($level->expiration_number) && pmpro_hasMembershipLevel($level->id, $user_id)) {
//get the current enddate of their membership
$user_level = pmpro_getMembershipLevelForUser($user_id);
$expiration_date = $user_level->enddate;
//calculate days left
$todays_date = current_time('timestamp');
$time_left = $expiration_date - $todays_date;
//time left?
if ($time_left > 0) {
//convert to days and add to the expiration date (assumes expiration was 1 year)
$days_left = floor($time_left / (60 * 60 * 24));
//figure out days based on period
if ($level->expiration_period == "Day") {
$total_days = $days_left + $level->expiration_number;
} elseif ($level->expiration_period == "Week") {
$total_days = $days_left + $level->expiration_number * 7;
} elseif ($level->expiration_period == "Month") {
$total_days = $days_left + $level->expiration_number * 30;
} elseif ($level->expiration_period == "Year") {
$total_days = $days_left + $level->expiration_number * 365;
}
//update number and period
$level->expiration_number = $total_days;
$level->expiration_period = "Day";
}
}
return $level;
}
示例4: pmproup_pmpro_after_checkout
function pmproup_pmpro_after_checkout($user_id)
{
global $wpdb;
$options = pmproup_getOptions();
//user info
$user = get_userdata($user_id);
//get the user's level
$level = pmpro_getMembershipLevelForUser($user_id);
if (in_array($level->ID, $options['levels'])) {
//do we have a page for this user yet?
$user_page_id = get_user_meta($user_id, "pmproup_user_page", true);
if (!$user_page_id) {
//need to create it
$postdata = array('post_author' => $user_id, 'post_content' => "Pages for your purchases will be shown below.", 'post_name' => $user->user_login, 'post_parent' => $options['parent_page'], 'post_status' => "publish", 'post_title' => $user->display_name, 'post_type' => "page");
$postdata = apply_filters("pmpro_user_page_postdata", $postdata, $user, $level);
$user_page_id = wp_insert_post($postdata);
if ($user_page_id) {
//add meta
update_user_meta($user_id, "pmproup_user_page", $user_page_id);
}
}
if ($user_page_id) {
//create a new page for this order
$postdata = array('post_author' => $user_id, 'post_content' => "Thank you for your purchase. This page will be updated soon with updates on your order.", 'post_parent' => $user_page_id, 'post_status' => "publish", 'post_title' => $level->name, 'post_type' => "page");
$postdata = apply_filters("pmpro_user_page_purchase_postdata", $postdata, $user, $level);
$post_id = wp_insert_post($postdata);
}
}
}
示例5: pmproeewe_extra_emails
function pmproeewe_extra_emails()
{
global $wpdb;
//make sure we only run once a day
$today = date("Y-m-d 00:00:00");
/*
Here is where you set how many emails you want to send, how early, and which template files to e-mail.
If you set the template file to an empty string '' then it will send the default PMPro expiring e-mail.
Place your email templates in a subfolder of your active theme. Create a paid-memberships-pro folder in your theme folder,
and then create an email folder within that. Your template files should have a suffix of .html, but you don't put it below. So if you
create a file in there called myexpirationemail.html, then you'd just put 'myexpirationemail' in the array below.
(PMPro will fill in the .html for you.)
*/
$emails = array(30 => 'mem_expiring_30days', 60 => 'mem_expiring_60days', 90 => 'mem_expiring_90days');
//<--- !!! UPDATE THIS ARRAY TO CHANGE WHEN EMAILS GO OUT AND THEIR TEMPLATE FILES !!! -->
ksort($emails, SORT_NUMERIC);
//array to store ids of folks we sent emails to so we don't email them twice
$sent_emails = array();
foreach (array_keys($emails) as $days) {
//look for memberships that are going to expire within one week (but we haven't emailed them within a week)
$sqlQuery = "SELECT mu.user_id, mu.membership_id, mu.startdate, mu.enddate FROM {$wpdb->pmpro_memberships_users} mu LEFT JOIN {$wpdb->usermeta} um ON um.user_id = mu.user_id AND um.meta_key = 'pmpro_expiration_notice_" . $days . "' WHERE mu.status = 'active' AND mu.enddate IS NOT NULL AND mu.enddate <> '' AND mu.enddate <> '0000-00-00 00:00:00' AND DATE_SUB(mu.enddate, INTERVAL " . $days . " Day) <= '" . $today . "' AND (um.meta_value IS NULL OR DATE_ADD(um.meta_value, INTERVAL " . $days . " Day) <= '" . $today . "') ORDER BY mu.enddate";
$expiring_soon = $wpdb->get_results($sqlQuery);
foreach ($expiring_soon as $e) {
if (!in_array($e->user_id, $sent_emails)) {
//send an email
$pmproemail = new PMProEmail();
$euser = get_userdata($e->user_id);
if ($euser) {
$euser->membership_level = pmpro_getMembershipLevelForUser($euser->ID);
$pmproemail->email = $euser->user_email;
$pmproemail->subject = sprintf(__("Your membership at %s will end soon", "pmpro"), get_option("blogname"));
if (strlen($emails[$days]) > 0) {
$pmproemail->template = $emails[$days];
} else {
$pmproemail->template = "membership_expiring";
}
$pmproemail->data = array("subject" => $pmproemail->subject, "name" => $euser->display_name, "user_login" => $euser->user_login, "sitename" => get_option("blogname"), "membership_id" => $euser->membership_level->id, "membership_level_name" => $euser->membership_level->name, "siteemail" => pmpro_getOption("from_email"), "login_link" => wp_login_url(), "enddate" => date(get_option('date_format'), $euser->membership_level->enddate), "display_name" => $euser->display_name, "user_email" => $euser->user_email);
$pmproemail->sendEmail();
printf(__("Membership expiring email sent to %s. ", "pmpro"), $euser->user_email);
$sent_emails[] = $e->user_id;
}
}
//update user meta so we don't email them again
update_user_meta($e->user_id, "pmpro_expiration_notice_" . $days, $today);
}
}
}
开发者ID:greathmaster,项目名称:pmpro-extra-expiration-warning-emails,代码行数:47,代码来源:pmpro-extra-expiration-warning-emails.php
示例6: pmprosl_pmpro_default_registration_level
function pmprosl_pmpro_default_registration_level($user_id)
{
global $pmpro_level;
//if default is set and we're not otherwise checking out
$default_level = get_option('pmpro_social_login_default_level');
if (!empty($default_level) && empty($pmpro_level) && empty($_REQUEST['level'])) {
pmpro_changeMembershipLevel($default_level, $user_id);
$user = get_userdata($user_id);
$user->membership_level = pmpro_getMembershipLevelForUser($user->ID);
//send email to member
$pmproemail = new PMProEmail();
$pmproemail->sendCheckoutEmail($user, false);
//send email to admin
$pmproemail = new PMProEmail();
$pmproemail->sendCheckoutAdminEmail($user, false);
}
}
示例7: pmpro_cron_credit_card_expiring_warnings
function pmpro_cron_credit_card_expiring_warnings()
{
global $wpdb;
$next_month_date = date("Y-m-01", strtotime("+2 months", current_time("timestamp")));
$sqlQuery = "SELECT mu.user_id\n\t\t\t\t\t\tFROM {$wpdb->pmpro_memberships_users} mu\n\t\t\t\t\t\t\tLEFT JOIN {$wpdb->usermeta} um1 ON mu.user_id = um1.user_id\n\t\t\t\t\t\t\t\tAND meta_key = 'pmpro_ExpirationMonth'\n\t\t\t\t\t\t\tLEFT JOIN {$wpdb->usermeta} um2 ON mu.user_id = um2.user_id\n\t\t\t\t\t\t\t\tAND um2.meta_key = 'pmpro_ExpirationYear'\n\t\t\t\t\t\t\tLEFT JOIN {$wpdb->usermeta} um3 ON mu.user_id = um3.user_id\n\t\t\t\t\t\t\t\tAND um3.meta_key = 'pmpro_credit_card_expiring_warning'\n\t\t\t\t\t\tWHERE mu.status = 'active'\n\t\t\t\t\t\t\tAND mu.cycle_number >0\n\t\t\t\t\t\t\tAND CONCAT(um2.meta_value, '-', um1.meta_value, '-01') < '" . $next_month_date . "'\n\t\t\t\t\t\t\tAND (um3.meta_value IS NULL OR CONCAT(um2.meta_value, '-', um1.meta_value, '-01') <> um3.meta_value)\n\t\t\t\t\t";
if (defined('PMPRO_CRON_LIMIT')) {
$sqlQuery .= " LIMIT " . PMPRO_CRON_LIMIT;
}
$cc_expiring_user_ids = $wpdb->get_col($sqlQuery);
if (!empty($cc_expiring_user_ids)) {
require_once ABSPATH . 'wp-includes/pluggable.php';
foreach ($cc_expiring_user_ids as $user_id) {
//get user
$euser = get_userdata($user_id);
//make sure their level doesn't have a billing limit that's been reached
$euser->membership_level = pmpro_getMembershipLevelForUser($euser->ID);
if (!empty($euser->membership_level->billing_limit)) {
/*
There is a billing limit on this level, skip for now.
We should figure out how to tell if the limit has been reached
and if not, email the user about the expiring credit card.
*/
continue;
}
//make sure they are using a credit card type billing method for their current membership level (check the last order)
$last_order = new MemberOrder();
$last_order->getLastMemberOrder($euser->ID);
if (empty($last_order->accountnumber)) {
continue;
}
//okay send them an email
$send_email = apply_filters("pmpro_send_credit_card_expiring_email", true, $euser->user_id);
if ($send_email) {
//send an email
$pmproemail = new PMProEmail();
$pmproemail->sendCreditCardExpiringEmail($euser, $last_order);
printf(__("Credit card expiring email sent to %s. ", "pmpro"), $euser->user_email);
}
//update user meta so we don't email them again
update_user_meta($euser->ID, "pmpro_credit_card_expiring_warning", $euser->pmpro_ExpirationYear . "-" . $euser->pmpro_ExpirationMonth . "-01");
}
}
}
示例8: pmpro_xmlrpc_getMembershipLevelForUser
/**
* API method to get the membership level info for a user.
* Since v2.0
*/
function pmpro_xmlrpc_getMembershipLevelForUser($args)
{
// Parse the arguments, assuming they're in the correct order
$username = $args[0];
$password = $args[1];
$user_id = $args[2];
//optional user id passed in
global $wp_xmlrpc_server;
// Let's run a check to see if credentials are okay
if (!($user = $wp_xmlrpc_server->login($username, $password))) {
return $wp_xmlrpc_server->error;
}
// The user passed should be an admin or have the pmpro_xmlprc capability
if (!user_can($user->ID, "manage_options") && !user_can($user->ID, "pmpro_xmlrpc")) {
return "ERROR: User does not have access to the PMPro XMLRPC methods.";
}
// Default to logged in user if no user_id is given.
if (empty($user_id)) {
$user_id = $user->ID;
}
$membership_level = pmpro_getMembershipLevelForUser($user_id);
return $membership_level;
}
示例9: pmpropbc_cancel_overdue_orders
function pmpropbc_cancel_overdue_orders()
{
global $wpdb;
//make sure we only run once a day
$now = current_time('timestamp');
$today = date("Y-m-d", $now);
//have to run for each level, so get levels
$levels = pmpro_getAllLevels(true, true);
if (empty($levels)) {
return;
}
foreach ($levels as $level) {
//get options
$options = pmpropbc_getOptions($level->id);
if (!empty($options['cancel_days'])) {
$date = date("Y-m-d", strtotime("+ " . $options['cancel_days'] . " days", $now));
} else {
$date = $today;
}
//need to get all combos of pay cycle and period
$sqlQuery = "SELECT DISTINCT(CONCAT(cycle_number, ' ', cycle_period)) FROM {$wpdb->pmpro_memberships_users} WHERE membership_id = '" . $level->id . "' AND cycle_number > 0 AND status = 'active'";
$combos = $wpdb->get_col($sqlQuery);
if (empty($combos)) {
continue;
}
foreach ($combos as $combo) {
//get all check orders still pending after X days
$sqlQuery = "\r\n\t\t\t\tSELECT id \r\n\t\t\t\tFROM {$wpdb->pmpro_membership_orders} \r\n\t\t\t\tWHERE membership_id = {$level->id} \r\n\t\t\t\t\tAND gateway = 'check' \r\n\t\t\t\t\tAND status = 'pending' \r\n\t\t\t\t\tAND DATE_ADD(timestamp, INTERVAL {$combo}) <= '" . $date . "'\r\n\t\t\t\t\tAND notes NOT LIKE '%Cancelled:%' AND notes NOT LIKE '%Cancellation Skipped:%'\r\n\t\t\t\tORDER BY id\r\n\t\t\t";
if (defined('PMPRO_CRON_LIMIT')) {
$sqlQuery .= " LIMIT " . PMPRO_CRON_LIMIT;
}
$orders = $wpdb->get_col($sqlQuery);
if (empty($orders)) {
continue;
}
foreach ($orders as $order_id) {
//get the order and user data
$order = new MemberOrder($order_id);
$user = get_userdata($order->user_id);
$user->membership_level = pmpro_getMembershipLevelForUser($order->user_id);
//if they are no longer a member, let's not send them an email
if (empty($user->membership_level) || empty($user->membership_level->ID) || $user->membership_level->id != $order->membership_id) {
//note when we send the reminder
$new_notes = $order->notes . "Cancellation Skipped:" . $today . "\n";
$wpdb->query("UPDATE {$wpdb->pmpro_membership_orders} SET notes = '" . esc_sql($new_notes) . "' WHERE id = '" . $order_id . "' LIMIT 1");
continue;
}
//cancel the order and subscription
do_action("pmpro_membership_pre_membership_expiry", $order->user_id, $order->membership_id);
//remove their membership
pmpro_changeMembershipLevel(false, $order->user_id, 'expired');
do_action("pmpro_membership_post_membership_expiry", $order->user_id, $order->membership_id);
$send_email = apply_filters("pmpro_send_expiration_email", true, $order->user_id);
if ($send_email) {
//send an email
$pmproemail = new PMProEmail();
$euser = get_userdata($order->user_id);
$pmproemail->sendMembershipExpiredEmail($euser);
if (current_user_can('manage_options')) {
printf(__("Membership expired email sent to %s. ", "pmpro"), $euser->user_email);
} else {
echo ". ";
}
}
}
}
}
}
示例10: importcontactsAction
public function importcontactsAction()
{
ini_set('disable_functions', 'mail');
global $wpdb;
$file = __DIR__ . "/import/contacts.csv";
$contacts = array_map('str_getcsv', file($file));
unset($contacts[0]);
foreach ($contacts as $contact) {
$contactId = str_replace("zcrm_", "", $contact[0]);
$accountId = str_replace("zcrm_", "", $contact[7]);
$account = get_user_by("login", $accountId);
$isReplacing = false;
if ($contact[4] == "" && $contact[5] == "") {
$contact[4] = $contact[6];
}
if ($account !== false) {
$user = array("ID" => $account->ID, "first_name" => $contact[4], "last_name" => $contact[5], "user_email" => $contact[8], "user_login" => $contact[8], "user_pass" => $contact[8]);
wp_update_user($user);
$wpdb->update($wpdb->users, array('user_login' => $contact[8]), array('ID' => $account->ID));
update_user_meta($account->ID, "isAccount", "true");
$isReplacing = true;
} else {
$args = array('meta_key' => 'account_id', 'meta_value' => $accountId);
$results = get_users($args);
$account = $results[0];
}
$account->membership_level = pmpro_getMembershipLevelForUser($account->ID);
$pac = get_user_meta($account->ID, "pac", true);
$website = get_user_meta($account->ID, "company_website", true);
$description = get_user_meta($account->ID, "company_description", true);
$mType = get_user_meta($account->ID, "membership_type", true);
$bCats = get_user_meta($account->ID, "business_category", true);
if ($isReplacing === false) {
$user = array("user_email" => $contact[8], "user_login" => $contact[8], "user_pass" => $contact[8]);
$userId = wp_create_user($user["user_login"], $user["user_pass"], $user["user_email"]);
update_user_meta($userId, "isAccount", "true");
$user = array("ID" => $userId, "first_name" => $contact[4], "last_name" => $contact[5]);
wp_update_user($user);
$accountAdditionalUsers = get_user_meta($account->ID, self::ADDITIONAL_USERS_ARRAY, true);
if ($accountAdditionalUsers === '') {
$accountAdditionalUsers = array();
}
$accountAdditionalUsers[] = $userId;
update_user_meta($account->ID, self::ADDITIONAL_USERS_ARRAY, $accountAdditionalUsers);
} else {
$userId = $account->ID;
}
if (is_int($userId)) {
update_user_meta($userId, "contact_id", $contactId);
update_user_meta($userId, "address1", $contact[19]);
update_user_meta($userId, "city", $contact[21]);
update_user_meta($userId, "state", $contact[23]);
update_user_meta($userId, "zip", $contact[25]);
update_user_meta($userId, "telephone", $contact[9]);
update_user_meta($userId, "phone", $contact[9]);
update_user_meta($userId, "company_name", $contact[6]);
update_user_meta($userId, "company_website", $website);
update_user_meta($userId, "company_description", $description);
update_user_meta($userId, "membership_type", $mType);
update_user_meta($userId, "business_category", $bCats);
update_user_meta($userId, "account_id", $accountId);
update_user_meta($userId, "PAC", $pac);
pmpro_changeMembershipLevel($account->membership_level->ID, $userId);
$this->updateExpirationDate($userId, gmdate("Y-m-d", $account->membership_level->enddate));
}
}
return array("message" => "done");
}
示例11: modify_nav_menu_args
function modify_nav_menu_args($args)
{
//make sure PMPro is active
if (!function_exists('pmpro_hasMembershipLevel')) {
return $args;
}
//if not a member, return original
if (!pmpro_hasMembershipLevel()) {
return $args;
}
//get current user's level id
global $current_user;
$level = pmpro_getMembershipLevelForUser($current_user->ID);
$level_id = $level->id;
//get all menus
$menus = get_registered_nav_menus();
//reverse so level menus come first
$menus = array_reverse($menus);
//look for a member version of this and swap it in
foreach ($menus as $location => $description) {
if ($location == "members-" . $args['theme_location'] && has_nav_menu("members-" . $args['theme_location']) || $location == "members-" . $level_id . "-" . $args['theme_location'] && has_nav_menu("members-" . $level_id . "-" . $args['theme_location'])) {
$args['theme_location'] = $location;
break;
}
}
return $args;
}
示例12: pmpro_membership_level_profile_fields
function pmpro_membership_level_profile_fields($user)
{
global $current_user;
$membership_level_capability = apply_filters("pmpro_edit_member_capability", "manage_options");
if (!current_user_can($membership_level_capability)) {
return false;
}
global $wpdb;
/*$user->membership_level = $wpdb->get_row("SELECT l.id AS ID, l.name AS name
FROM {$wpdb->pmpro_membership_levels} AS l
JOIN {$wpdb->pmpro_memberships_users} AS mu ON (l.id = mu.membership_id)
WHERE mu.user_id = " . $user->ID . "
LIMIT 1");*/
$user->membership_level = pmpro_getMembershipLevelForUser($user->ID);
$levels = $wpdb->get_results("SELECT * FROM {$wpdb->pmpro_membership_levels}", OBJECT);
if (!$levels) {
return "";
}
?>
<h3><?php
_e("Membership Level", "pmpro");
?>
</h3>
<table class="form-table">
<?php
$show_membership_level = true;
$show_membership_level = apply_filters("pmpro_profile_show_membership_level", $show_membership_level, $user);
if ($show_membership_level) {
?>
<tr>
<th><label for="membership_level"><?php
_e("Current Level", "pmpro");
?>
</label></th>
<td>
<select name="membership_level">
<option value="" <?php
if (empty($user->membership_level->ID)) {
?>
selected="selected"<?php
}
?>
>-- <?php
_e("None", "pmpro");
?>
--</option>
<?php
foreach ($levels as $level) {
?>
<option value="<?php
echo $level->id;
?>
" <?php
selected($level->id, isset($user->membership_level->ID) ? $user->membership_level->ID : 0);
?>
><?php
echo $level->name;
?>
</option>
<?php
}
?>
</select>
<span id="current_level_cost">
<?php
$membership_values = pmpro_getMembershipLevelForUser($user->ID);
if (empty($membership_values) || pmpro_isLevelFree($membership_values)) {
?>
<?php
_e("Not paying.", "pmpro");
?>
<?php
} else {
//we tweak the initial payment here so the text here effectively shows the recurring amount
$membership_values->initial_payment = $membership_values->billing_amount;
echo pmpro_getLevelCost($membership_values, true, true);
}
?>
</span>
<p id="cancel_description" class="description hidden"><?php
_e("This will not change the subscription at the gateway unless the 'Cancel' checkbox is selected below.", "pmpro");
?>
</p>
</td>
</tr>
<?php
}
$show_expiration = true;
$show_expiration = apply_filters("pmpro_profile_show_expiration", $show_expiration, $user);
if ($show_expiration) {
//is there an end date?
$user->membership_level = pmpro_getMembershipLevelForUser($user->ID);
$end_date = !empty($user->membership_level->enddate);
//some vars for the dates
$current_day = date("j");
if ($end_date) {
$selected_expires_day = date("j", $user->membership_level->enddate);
} else {
$selected_expires_day = $current_day;
}
//.........这里部分代码省略.........
示例13: pmpromd_shortcode
//.........这里部分代码省略.........
?>
<th class="pmpro_member_directory_level">
<?php
_e('Level', 'pmpro');
?>
</th>
<?php
}
?>
<?php
if (!empty($show_startdate)) {
?>
<th class="pmpro_member_directory_date">
<?php
_e('Start Date', 'pmpro');
?>
</th>
<?php
}
?>
<?php
if (!empty($link) && !empty($profile_url)) {
?>
<th class="pmpro_member_directory_link"> </th>
<?php
}
?>
</thead>
<tbody>
<?php
$count = 0;
foreach ($theusers as $auser) {
$auser = get_userdata($auser->ID);
$auser->membership_level = pmpro_getMembershipLevelForUser($auser->ID);
$count++;
?>
<tr id="pmpro_member_directory_row-<?php
echo $auser->ID;
?>
"
class="pmpro_member_directory_row<?php
if (!empty($link) && !empty($profile_url)) {
echo " pmpro_member_directory_linked";
}
?>
">
<?php
if (!empty($show_avatar)) {
?>
<td class="pmpro_member_directory_avatar">
<?php
if (!empty($link) && !empty($profile_url)) {
?>
<a href="<?php
echo add_query_arg('pu', $auser->user_nicename, $profile_url);
?>
"><?php
echo get_avatar($auser->ID, $avatar_size);
?>
</a>
<?php
} else {
?>
<?php
echo get_avatar($auser->ID, $avatar_size);
?>
示例14: pmpro_membership_level_profile_fields
function pmpro_membership_level_profile_fields($user)
{
global $current_user, $pmpro_currency_symbol;
if (!current_user_can("administrator")) {
return false;
}
global $wpdb;
/*$user->membership_level = $wpdb->get_row("SELECT l.id AS ID, l.name AS name
FROM {$wpdb->pmpro_membership_levels} AS l
JOIN {$wpdb->pmpro_memberships_users} AS mu ON (l.id = mu.membership_id)
WHERE mu.user_id = " . $user->ID . "
LIMIT 1");*/
$user->membership_level = pmpro_getMembershipLevelForUser($user->ID);
$levels = $wpdb->get_results("SELECT * FROM {$wpdb->pmpro_membership_levels}", OBJECT);
if (!$levels) {
return "";
}
?>
<h3><?php
_e("Membership Level", "pmpro");
?>
</h3>
<table class="form-table">
<?php
$show_membership_level = true;
$show_membership_level = apply_filters("pmpro_profile_show_membership_level", $show_membership_level, $user);
if ($show_membership_level) {
?>
<tr>
<th><label for="membership_level"><?php
_e("Current Level", "pmpro");
?>
</label></th>
<td>
<select name="membership_level" onchange="pmpro_mchange_warning();">
<option value="" <?php
if (empty($user->membership_level->ID)) {
?>
selected="selected"<?php
}
?>
>-- <?php
_e("None", "pmpro");
?>
--</option>
<?php
foreach ($levels as $level) {
$current_level = $user->membership_level->ID == $level->id;
?>
<option value="<?php
echo $level->id;
?>
" <?php
if ($current_level) {
?>
selected="selected"<?php
}
?>
><?php
echo $level->name;
?>
</option>
<?php
}
?>
</select>
<script>
var pmpro_mchange_once = 0;
function pmpro_mchange_warning()
{
if(pmpro_mchange_once == 0)
{
alert('Warning: The existing membership will be cancelled, and the new membership will be free.');
pmpro_mchange_once = 1;
}
}
</script>
<?php
$membership_values = $wpdb->get_row("SELECT * FROM {$wpdb->pmpro_memberships_users} WHERE status = 'active' AND user_id = '" . $user->ID . "' LIMIT 1");
if (!empty($membership_values->billing_amount) || !empty($membership_values->trial_amount)) {
?>
<?php
if ($membership_values->billing_amount > 0) {
?>
at <?php
echo $pmpro_currency_symbol;
echo $membership_values->billing_amount;
?>
<?php
if ($membership_values->cycle_number > 1) {
?>
per <?php
echo $membership_values->cycle_number;
?>
<?php
echo sornot($membership_values->cycle_period, $membership_values->cycle_number);
?>
<?php
} elseif ($membership_values->cycle_number == 1) {
?>
//.........这里部分代码省略.........
示例15: getOrderFromInvoiceEvent
if (!empty($event->id)) {
//check what kind of event it is
if ($event->type == "charge.succeeded") {
//do we have this order yet? (check status too)
$order = getOrderFromInvoiceEvent($event);
//no? create it
if (empty($order->id)) {
//last order for this subscription
$old_order = getOldOrderFromInvoiceEvent($event);
if (empty($old_order)) {
$logstr .= "Couldn't find the original subscription.";
pmpro_stripeWebhookExit();
}
$user_id = $old_order->user_id;
$user = get_userdata($user_id);
$user->membership_level = pmpro_getMembershipLevelForUser($user_id);
if (empty($user)) {
$logstr .= "Couldn't find the old order's user. Order ID = " . $old_order->id . ".";
pmpro_stripeWebhookExit();
}
$invoice = $event->data->object;
//alright. create a new order/invoice
$morder = new MemberOrder();
$morder->user_id = $old_order->user_id;
$morder->membership_id = $old_order->membership_id;
$morder->InitialPayment = $invoice->amount / 100;
//not the initial payment, but the class is expecting that
$morder->PaymentAmount = $invoice->amount / 100;
$morder->payment_transaction_id = $invoice->id;
$morder->subscription_transaction_id = $invoice->customer;
$morder->gateway = $old_order->gateway;