Exemple #1
0
    echo $level->name;
    ?>
</li>
		<?php 
    if ($level->billing_amount > 0) {
        ?>
			<li><strong><?php 
        _e("Membership Fee", "vibe");
        ?>
:</strong>
				<?php 
        $level = $current_user->membership_level;
        if ($current_user->membership_level->cycle_number > 1) {
            printf(_x('%s every %d %s.', 'Recurring payment in cost text generation. E.g., $5 every 2 months.', 'vibe'), $pmpro_currency_symbol . $level->billing_amount, $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number));
        } elseif ($current_user->membership_level->cycle_number == 1) {
            printf(_x('%s per %s.', 'Recurring payment in cost text generation. E.g. $5 every month.', 'vibe'), $pmpro_currency_symbol . $level->billing_amount, pmpro_translate_billing_period($level->cycle_period));
        } else {
            echo $pmpro_currency_symbol, $current_user->membership_level->billing_amount;
        }
        ?>
			</li>
		<?php 
    }
    ?>

		<?php 
    if ($level->billing_limit) {
        ?>
			<li><strong><?php 
        _e("Duration", "vibe");
        ?>
Exemple #2
0
 if (pmpro_isLevelFree($level)) {
     echo "<strong>" . __('Free', 'pmpro') . "</strong>";
 } elseif ($level->billing_amount != '0.00') {
     if ($level->billing_limit > 1) {
         if ($level->cycle_number == '1') {
             printf(_x('%s per %s for %d more %s.', 'Recurring payment in cost text generation. E.g. $5 every month for 2 more payments.', 'kleo_framework'), $pmpro_currency_symbol . $level->billing_amount, pmpro_translate_billing_period($level->cycle_period), $level->billing_limit, pmpro_translate_billing_period($level->cycle_period, $level->billing_limit));
         } else {
             printf(_x('%s every %d %s for %d more %s.', 'Recurring payment in cost text generation. E.g., $5 every 2 months for 2 more payments.', 'kleo_framework'), $pmpro_currency_symbol . $level->billing_amount, $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number), $level->billing_limit, pmpro_translate_billing_period($level->cycle_period, $level->billing_limit));
         }
     } elseif ($level->billing_limit == 1) {
         printf(_x('%s after %d %s.', 'Recurring payment in cost text generation. E.g. $5 after 2 months.', 'kleo_framework'), $pmpro_currency_symbol . $level->billing_amount, $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number));
     } else {
         if ($level->cycle_number == '1') {
             printf(_x('%s per %s.', 'Recurring payment in cost text generation. E.g. $5 every month.', 'kleo_framework'), $pmpro_currency_symbol . $level->billing_amount, pmpro_translate_billing_period($level->cycle_period));
         } else {
             printf(_x('%s every %d %s.', 'Recurring payment in cost text generation. E.g., $5 every 2 months.', 'kleo_framework'), $pmpro_currency_symbol . $level->billing_amount, $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number));
         }
     }
 }
 //trial
 if (pmpro_isLevelTrial($level)) {
     if ($level->trial_amount == '0.00') {
         if ($level->trial_limit == '1') {
             echo ' ' . _x('After your initial payment, your first payment is Free.', 'Trial payment in cost text generation.', 'pmpro');
         } else {
             printf(' ' . _x('After your initial payment, your first %d payments are Free.', 'Trial payment in cost text generation.', 'pmpro'), $level->trial_limit);
         }
     } else {
         if ($level->trial_limit == '1') {
             printf(' ' . _x('After your initial payment, your first payment will cost %s.', 'Trial payment in cost text generation.', 'pmpro'), $pmpro_currency_symbol . $level->trial_amount);
         } else {
function pmpro_getLevelExpiration(&$level)
{
    if ($level->expiration_number) {
        $expiration_text = sprintf(__("Membership expires after %d %s.", "pmpro"), $level->expiration_number, pmpro_translate_billing_period($level->expiration_period, $level->expiration_number));
    } else {
        $expiration_text = "";
    }
    $expiration_text = apply_filters("pmpro_level_expiration_text", $expiration_text, $level);
    return $expiration_text;
}
    echo $level->name;
    ?>
</li>
		<?php 
    if ($level->billing_amount > 0) {
        ?>
			<li><strong><?php 
        _e("Membership Fee", "pmpro");
        ?>
:</strong>
				<?php 
        $level = $current_user->membership_level;
        if ($current_user->membership_level->cycle_number > 1) {
            printf(__('%s every %d %s.', 'pmpro'), pmpro_formatPrice($level->billing_amount), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number));
        } elseif ($current_user->membership_level->cycle_number == 1) {
            printf(__('%s per %s.', 'pmpro'), pmpro_formatPrice($level->billing_amount), pmpro_translate_billing_period($level->cycle_period));
        } else {
            echo pmpro_formatPrice($current_user->membership_level->billing_amount);
        }
        ?>
			</li>
		<?php 
    }
    ?>

		<?php 
    if ($level->billing_limit) {
        ?>
			<li><strong><?php 
        _e("Duration", "pmpro");
        ?>
Exemple #5
0
    echo $current_user->membership_level->name;
    ?>
</li>
			<?php 
    if ($current_user->membership_level->billing_amount > 0) {
        ?>
				<li><strong><?php 
        _e("Membership Fee", "pmpro");
        ?>
:</strong>
				<?php 
        $level = $current_user->membership_level;
        if ($current_user->membership_level->cycle_number > 1) {
            printf(__('%s every %d %s.', 'pmpro'), $pmpro_currency_symbol . $level->billing_amount, $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number));
        } elseif ($current_user->membership_level->cycle_number == 1) {
            printf(__('%s per %s.', 'pmpro'), $pmpro_currency_symbol . $level->billing_amount, pmpro_translate_billing_period($level->cycle_period));
        } else {
            echo $pmpro_currency_symbol, $current_user->membership_level->billing_amount;
        }
        ?>
				</li>
			<?php 
    }
    ?>
						
			
			<?php 
    if ($current_user->membership_level->billing_limit) {
        ?>
				<li><strong><?php 
        _e("Duration", "pmpro");
        if (!pmpro_isLevelRecurring($level)) {
            ?>
					--
				<?php 
        } else {
            ?>
						
					<?php 
            echo $pmpro_currency_symbol;
            echo $level->billing_amount;
            ?>
 <?php 
            _e('every', 'pmpro');
            ?>
 <?php 
            echo $level->cycle_number . ' ' . pmpro_translate_billing_period($level->cycle_period, $level->cycle_number);
            ?>
					
					<?php 
            if ($level->billing_limit) {
                ?>
(<?php 
                _e('for', 'pmpro');
                ?>
 <?php 
                echo $level->billing_limit;
                ?>
 <?php 
                echo sornot($level->cycle_period, $level->billing_limit);
                ?>
)<?php 
Exemple #7
0
function memberlite_getLevelCost(&$level, $tags = true, $short = false)
{
    $r = '<span class="pmpro_level-initialprice">';
    //initial payment
    if (!$short) {
        $r .= sprintf(__('The price for membership is <strong>%s</strong> now', 'pmpro'), pmpro_formatPrice($level->initial_payment));
    } elseif (pmpro_isLevelFree($level)) {
        $r .= sprintf(__('<strong>FREE</strong>', 'pmpro'));
    } else {
        $r .= sprintf(__('<strong>%s</strong> now', 'pmpro'), pmpro_formatPrice($level->initial_payment));
    }
    $r .= '</span>';
    //recurring part
    if ($level->billing_amount != '0.00') {
        if ($level->billing_limit > 1) {
            if ($level->cycle_number == '1') {
                $r .= sprintf(__(' and then <strong>%s per %s for %d more %s</strong>.', 'pmpro'), pmpro_formatPrice($level->billing_amount), pmpro_translate_billing_period($level->cycle_period), $level->billing_limit, pmpro_translate_billing_period($level->cycle_period, $level->billing_limit));
            } else {
                $r .= sprintf(__(' and then <strong>%s every %d %s for %d more %s</strong>.', 'pmpro'), pmpro_formatPrice($level->billing_amount), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number), $level->billing_limit, pmpro_translate_billing_period($level->cycle_period, $level->billing_limit));
            }
        } elseif ($level->billing_limit == 1) {
            $r .= sprintf(__(' and then <strong>%s after %d %s</strong>.', 'pmpro'), pmpro_formatPrice($level->billing_amount), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number));
        } else {
            if ($level->billing_amount === $level->initial_payment) {
                if ($level->cycle_number == '1') {
                    if (!$short) {
                        $r = sprintf(__('The price for membership is <strong>%s per %s</strong>.', 'pmpro'), pmpro_formatPrice($level->initial_payment), pmpro_translate_billing_period($level->cycle_period));
                    } else {
                        $r = sprintf(__('<strong>%s/%s</strong>', 'pmpro'), pmpro_formatPrice($level->initial_payment), pmpro_translate_billing_period($level->cycle_period));
                    }
                } else {
                    if (!$short) {
                        $r = sprintf(__('The price for membership is <strong>%s every %d %s</strong>.', 'pmpro'), pmpro_formatPrice($level->initial_payment), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number));
                    } else {
                        $r = sprintf(__('<strong>%s every %d %s</strong>.', 'pmpro'), pmpro_formatPrice($level->initial_payment), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number));
                    }
                }
            } else {
                $r .= '<span class="pmpro_level-subprice">';
                if ($level->cycle_number == '1') {
                    if (!$short) {
                        $r .= sprintf(__(' and then <strong>%s per %s</strong>.', 'pmpro'), pmpro_formatPrice($level->billing_amount), pmpro_translate_billing_period($level->cycle_period));
                    } else {
                        $r .= sprintf(__(' then <strong>%s/%s</strong>.', 'pmpro'), pmpro_formatPrice($level->billing_amount), pmpro_translate_billing_period($level->cycle_period));
                    }
                } else {
                    $r .= sprintf(__(' and then <strong>%s every %d %s</strong>.', 'pmpro'), pmpro_formatPrice($level->billing_amount), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number));
                }
                $r .= '</span>';
            }
        }
    } elseif (!pmpro_isLevelFree($level)) {
        $r .= ".";
    }
    //add a space
    $r .= ' ';
    //trial part
    if ($level->trial_limit) {
        $r .= '<span class="pmpro_level-trialprice">';
        if ($level->trial_amount == '0.00') {
            if ($level->trial_limit == '1') {
                $r .= ' ' . __('After your initial payment, your first payment is Free.', 'pmpro');
            } else {
                $r .= ' ' . sprintf(__('After your initial payment, your first %d payments are Free.', 'pmpro'), $level->trial_limit);
            }
        } else {
            if ($level->trial_limit == '1') {
                $r .= ' ' . sprintf(__('After your initial payment, your first payment will cost %s.', 'pmpro'), pmpro_formatPrice($level->trial_amount));
            } else {
                $r .= ' ' . sprintf(__('After your initial payment, your first %d payments will cost %s.', 'pmpro'), $level->trial_limit, pmpro_formatPrice($level->trial_amount));
            }
        }
        $r .= '</span>';
    }
    //taxes part
    $tax_state = pmpro_getOption("tax_state");
    $tax_rate = pmpro_getOption("tax_rate");
    if ($tax_state && $tax_rate && !pmpro_isLevelFree($level)) {
        $r .= '<span class="pmpro_level-tax">';
        $r .= sprintf(__('Customers in %s will be charged %s%% tax.', 'pmpro'), $tax_state, round($tax_rate * 100, 2));
        $r .= '</span>';
    }
    if (!$tags) {
        $r = strip_tags($r);
    }
    $r = apply_filters("pmpro_level_cost_text", $r, $level, $tags, $short);
    //passing $tags and $short since v2.0
    return $r;
}
function pmpro_getLevelsExpiration(&$levels)
{
    $expirystrings = array();
    $ongoinglevelnum = 0;
    if (!empty($levels) && !is_array($levels)) {
        $levels = array($levels);
    } elseif (empty($levels)) {
        $levels = array();
    }
    foreach ($levels as $curlevel) {
        if ($curlevel->expiration_number) {
            $expirystrings[] = sprintf(__("%s membership expires after %d %s", "pmpro"), $curlevel->name, $curlevel->expiration_number, pmpro_translate_billing_period($curlevel->expiration_period, $curlevel->expiration_number));
        } else {
            $ongoinglevelnum++;
        }
    }
    $expiration_text = "";
    if (count($expirystrings) > 0) {
        $laststanza = array_pop($expirystrings);
        $expiration_text = implode(', ', $expirystrings);
        if (count($expirystrings) > 0) {
            $expiration_text .= ", and ";
        }
        $expiration_text .= $laststanza;
        $expiration_text .= ". ";
        if ($ongoinglevelnum > 0) {
            $expiration_text .= "The remaining membership";
            if ($ongoinglevelnum > 1) {
                $expiration_text .= "s are";
            } else {
                $expiration_text .= " is";
            }
            $expiration_text .= " ongoing.";
        }
    }
    /**
     * Filter the levels expiration text. Note the s in levels. Similar to pmpro_levels_expiration_text
     */
    $expiration_text = apply_filters("pmpro_levels_expiration_text", $expiration_text, $levels);
    $expiration_text = apply_filters("pmpro_level_expiration_text", $expiration_text, $levels);
    // Backwards compatible
    return $expiration_text;
}
function billing_content_func($atts)
{
    global $wpdb, $pmpro_msg, $pmpro_msgt, $pmpro_levels, $current_user, $levels;
    //-> If a member is logged in, show them some info here (1. past invoices. 2. billing information with button to update.)
    if ($current_user->membership_level->ID) {
        if ($pmpro_msg) {
            ?>
            <div class="pmpro_message <?php 
            echo $pmpro_msgt;
            ?>
"><?php 
            echo $pmpro_msg;
            ?>
</div>
            <?php 
        }
        ?>
	
        <div class="row billing-content">
            <div class="col-md-8 col-sm-8 col-sm-offset-3 col-md-offset-3">
                <!-- BEGIN CONTENT-->
                <div id="pmpro_account">		
                    <div id="pmpro_account-membership" class="pmpro_box-first">

                        <?php 
        //wpex_logo();
        ?>
                        <!--
                        <div class="clear clearfix"></div>
                        <br/>
                        -->
                        <?php 
        $level = $current_user->membership_level->name;
        ?>
                        <p><?php 
        _e("Membership status: <strong>" . $level . "</strong>", "pmpro");
        ?>
</p>
                        <?php 
        //die(var_dump($current_user));
        ?>
                        <ul>
                            <li><strong><?php 
        _e("Level", "pmpro");
        ?>
:</strong> <?php 
        echo $current_user->membership_level->name;
        ?>
</li>
                            <?php 
        if ($current_user->membership_level->billing_amount > 0) {
            ?>
                                <li><strong><?php 
            _e("Membership Fee", "pmpro");
            ?>
:</strong>
                                    <?php 
            $level = $current_user->membership_level;
            if ($current_user->membership_level->cycle_number > 1) {
                printf(__('%s every %d %s.', 'pmpro'), pmpro_formatPrice($level->billing_amount), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number));
            } elseif ($current_user->membership_level->cycle_number == 1) {
                printf(__('%s per %s.', 'pmpro'), pmpro_formatPrice($level->billing_amount), pmpro_translate_billing_period($level->cycle_period));
            } else {
                echo pmpro_formatPrice($current_user->membership_level->billing_amount);
            }
            ?>
                                </li>
                            <?php 
        }
        ?>
						

                            <?php 
        if ($current_user->membership_level->billing_limit) {
            ?>
                                <li><strong><?php 
            _e("Duration", "pmpro");
            ?>
:</strong> <?php 
            echo $current_user->membership_level->billing_limit . ' ' . sornot($current_user->membership_level->cycle_period, $current_user->membership_level->billing_limit);
            ?>
</li>
                            <?php 
        }
        ?>

                            <?php 
        if ($current_user->membership_level->enddate) {
            ?>
                                <li><strong><?php 
            _e("Next billing date", "pmpro");
            ?>
:</strong> <?php 
            echo date_i18n(get_option('date_format'), $current_user->membership_level->enddate);
            ?>
</li>
                            <?php 
        }
        ?>

                            <?php 
        if ($current_user->membership_level->trial_limit == 1) {
            printf(__("Your first payment will cost %s.", "pmpro"), pmpro_formatPrice($current_user->membership_level->trial_amount));
        } elseif (!empty($current_user->membership_level->trial_limit)) {
            printf(__("Your first %d payments will cost %s.", "pmpro"), $current_user->membership_level->trial_limit, pmpro_formatPrice($current_user->membership_level->trial_amount));
        }
        ?>
                        </ul>

                    </div> <!-- end pmpro_account-membership -->

                    <div id="pmpro_account-profile" class="pmpro_box hide">	
                        <?php 
        get_currentuserinfo();
        ?>
 
                        <h3><?php 
        _e("My Account", "pmpro");
        ?>
</h3>
                        <?php 
        if ($current_user->user_firstname) {
            ?>
                            <p><?php 
            echo $current_user->user_firstname;
            ?>
 <?php 
            echo $current_user->user_lastname;
            ?>
</p>
                        <?php 
        }
        ?>
                        <ul>
                            <li><strong><?php 
        _e("Username", "pmpro");
        ?>
:</strong> <?php 
        echo $current_user->user_login;
        ?>
</li>
                            <li><strong><?php 
        _e("Email", "pmpro");
        ?>
:</strong> <?php 
        echo $current_user->user_email;
        ?>
</li>
                        </ul>
                        <p>
                            <a href="<?php 
        echo admin_url('profile.php');
        ?>
"><?php 
        _e("Edit Profile", "pmpro");
        ?>
</a> |
                            <a href="<?php 
        echo admin_url('profile.php');
        ?>
"><?php 
        _ex("Change Password", "As in 'change password'.", "pmpro");
        ?>
</a>
                        </p>
                    </div> <!-- end pmpro_account-profile -->

                    <?php 
        //last invoice for current info
        //$ssorder = $wpdb->get_row("SELECT *, UNIX_TIMESTAMP(timestamp) as timestamp FROM $wpdb->pmpro_membership_orders WHERE user_id = '$current_user->ID' AND membership_id = '" . $current_user->membership_level->ID . "' AND status = 'success' ORDER BY timestamp DESC LIMIT 1");
        $ssorder = new MemberOrder();
        $ssorder->getLastMemberOrder();
        $invoices = $wpdb->get_results("SELECT *, UNIX_TIMESTAMP(timestamp) as timestamp FROM {$wpdb->pmpro_membership_orders} WHERE user_id = '{$current_user->ID}' ORDER BY timestamp DESC LIMIT 6");
        if (!empty($ssorder->id) && $ssorder->gateway != "check" && $ssorder->gateway != "paypalexpress" && $ssorder->gateway != "paypalstandard" && $ssorder->gateway != "twocheckout") {
            //default values from DB (should be last order or last update)
            $bfirstname = get_user_meta($current_user->ID, "pmpro_bfirstname", true);
            $blastname = get_user_meta($current_user->ID, "pmpro_blastname", true);
            $baddress1 = get_user_meta($current_user->ID, "pmpro_baddress1", true);
            $baddress2 = get_user_meta($current_user->ID, "pmpro_baddress2", true);
            $bcity = get_user_meta($current_user->ID, "pmpro_bcity", true);
            $bstate = get_user_meta($current_user->ID, "pmpro_bstate", true);
            $bzipcode = get_user_meta($current_user->ID, "pmpro_bzipcode", true);
            $bcountry = get_user_meta($current_user->ID, "pmpro_bcountry", true);
            $bphone = get_user_meta($current_user->ID, "pmpro_bphone", true);
            $bemail = get_user_meta($current_user->ID, "pmpro_bemail", true);
            $bconfirmemail = get_user_meta($current_user->ID, "pmpro_bconfirmemail", true);
            $CardType = get_user_meta($current_user->ID, "pmpro_CardType", true);
            $AccountNumber = hideCardNumber(get_user_meta($current_user->ID, "pmpro_AccountNumber", true), false);
            $ExpirationMonth = get_user_meta($current_user->ID, "pmpro_ExpirationMonth", true);
            $ExpirationYear = get_user_meta($current_user->ID, "pmpro_ExpirationYear", true);
            ?>
	

                        <div id="pmpro_account-billing" class="pmpro_box">
                            <h3><?php 
            _e("Billing Information", "pmpro");
            ?>
</h3>
                            <?php 
            if (!empty($baddress1)) {
                ?>
                                <p>
                                    <strong><?php 
                _e("Billing Address", "pmpro");
                ?>
</strong><br />
                                    <?php 
                echo $bfirstname . " " . $blastname;
                ?>
                                    <br />		
                                    <?php 
                echo $current_user->user_email;
                ?>
<br />
                                    <?php 
                echo $baddress1;
                ?>
<br />
                                    <?php 
                if ($baddress2) {
                    echo $baddress2 . "<br />";
                }
                ?>
                                    <?php 
                if ($bcity && $bstate) {
                    ?>
                                        <?php 
                    echo $bcity;
                    ?>
, <?php 
                    echo $bstate;
                    ?>
 <?php 
                    echo $bzipcode;
                    ?>
 <?php 
                    echo $bcountry;
                    ?>
                                    <?php 
                }
                ?>
                         
                                    <br />
                                    <?php 
                echo formatPhone($bphone);
                ?>
                                </p>
                            <?php 
            }
            ?>

                            <?php 
            if (!empty($AccountNumber)) {
                ?>
                                <p>
                                    <strong><?php 
                _e("Payment Method", "pmpro");
                ?>
</strong><br />
                                    <?php 
                echo $CardType;
                ?>
: <?php 
                echo last4($AccountNumber);
                ?>
 (<?php 
                echo $ExpirationMonth;
                ?>
/<?php 
                echo $ExpirationYear;
                ?>
)
                                </p>
                            <?php 
            }
            ?>

                            <?php 
            if (isset($ssorder->status) && $ssorder->status == "success" && (isset($ssorder->gateway) && in_array($ssorder->gateway, array("authorizenet", "paypal", "stripe", "braintree", "payflow", "cybersource")))) {
                ?>
                                <p><a href="<?php 
                echo pmpro_url("billing", "");
                ?>
"><?php 
                _e("Edit Billing Information", "pmpro");
                ?>
</a></p>
                                <?php 
            }
            ?>
                        </div> <!-- end pmpro_account-billing -->				
                        <?php 
        }
        ?>

                    <?php 
        if (!empty($invoices)) {
            ?>
                        <div id="pmpro_account-invoices" class="pmpro_box">
                            <h3><?php 
            _e("Past Invoices", "pmpro");
            ?>
</h3>
                            <ul>
                                <?php 
            $count = 0;
            foreach ($invoices as $invoice) {
                if ($count++ > 5) {
                    break;
                }
                ?>
                                    <li><a href="<?php 
                echo pmpro_url("invoice", "?invoice=" . $invoice->code);
                ?>
"><?php 
                echo date_i18n(get_option("date_format"), $invoice->timestamp);
                ?>
 (<?php 
                echo pmpro_formatPrice($invoice->total);
                ?>
)</a></li>
                                    <?php 
            }
            ?>
                            </ul>
                            <?php 
            //if ($count == 6) {
            ?>
                            <p><a href="<?php 
            echo pmpro_url("invoice");
            ?>
"><?php 
            _e("View All Invoices", "pmpro");
            ?>
</a></p>
                            <?php 
            //}
            ?>
                        </div> <!-- end pmpro_account-billing -->
                    <?php 
        }
        ?>
                    <!--
                    <p class="help-block">We have the following subscriptions available for our site. To join, simply click on the <strong>Change Subscription</strong> button to Change Membership Level.</p>
                    -->                  
                    <?php 
        //getLevels();
        ?>
	
                </div> <!-- end pmpro_account -->	

                <!-- END CONTENT-->
            </div>
        </div>
        <?php 
    } else {
        $user_id = $current_user->ID;
        //make sure we only run once a day
        $today = date("Y-m-d", current_time("timestamp"));
        //look for memberships that expired
        $sqlQuery = "SELECT mu.user_id, mu.membership_id, mu.startdate, mu.enddate FROM {$wpdb->pmpro_memberships_users} mu WHERE mu.status = 'expired' AND mu.enddate IS NOT NULL AND mu.enddate <> '' AND mu.enddate <> '0000-00-00 00:00:00' AND DATE(mu.enddate) <= '" . $today . "' AND mu.user_id = '" . $user_id . "' ORDER BY mu.enddate  LIMIT 1";
        $expired = $wpdb->get_results($sqlQuery);
        if (count($expired) > 0) {
            ?>
            <div class="row billing-content">
                <div class="col-md-8 col-sm-8 col-sm-offset-3 col-md-offset-3">
                    <!-- BEGIN CONTENT-->
                    <div id="pmpro_account">		
                        <div id="pmpro_account-membership" class="pmpro_box-first">
                            <?php 
            foreach ($expired as $e) {
                $level_id = $e->membership_id;
                $level = pmpro_getLevel($level_id);
                ?>
                                <div class="pmpro_message">Your "<?php 
                echo $level->name;
                ?>
" Membership has expired, please renew now <a href="<?php 
                echo pmpro_url("levels");
                ?>
"><?php 
                _e("here", "pmpro");
                ?>
</a>.</div>
                                <div id="pmpro_account-membership" class="pmpro_box-first">
                                    <?php 
                $level = $current_user->membership_level->name;
                ?>
                                    <p><?php 
                _e("Membership status: <strong>" . $level->name . "(Expired)</strong>", "pmpro");
                ?>
</p>
                                    <ul>
                                        <?php 
                if ($e->enddate) {
                    //die(var_dump($e->enddate));
                    ?>

                                            <li><strong><?php 
                    _e("Expiration billing date", "pmpro");
                    ?>
:  </strong> <?php 
                    echo " " . date_i18n(get_option('date_format'), strtotime($e->enddate));
                    ?>
</li>
                                        <?php 
                }
                ?>
                                    </ul>

                                </div> <!-- end pmpro_account-membership -->                               
                                <?php 
            }
            ?>
                        </div>
                    </div>
                </div>
            </div>
            <?php 
        }
    }
    ?>
    <?php 
}
function billing_content_func($atts)
{
    global $wpdb, $pmpro_msg, $pmpro_msgt, $pmpro_levels, $current_user, $levels;
    //-> If a member is logged in, show them some info here (1. past invoices. 2. billing information with button to update.)
    if ($current_user->membership_level->ID) {
        if ($pmpro_msg) {
            ?>
            <div class="pmpro_message <?php 
            echo $pmpro_msgt;
            ?>
"><?php 
            echo $pmpro_msg;
            ?>
</div>
            <?php 
        }
        ?>
	
        <div class="row">
            <div class="col-md-8 col-sm-8 col-sm-offset-2 col-md-offset-2">
                <!-- BEGIN CONTENT-->
                <div id="pmpro_account">		
                    <div id="pmpro_account-membership" class="pmpro_box">
                        <p><?php 
        _e("Your membership is <strong>active</strong>.", "pmpro");
        ?>
</p>
                        <ul>
                            <li><strong><?php 
        _e("Level", "pmpro");
        ?>
:</strong> <?php 
        echo $current_user->membership_level->name;
        ?>
</li>
                            <?php 
        if ($current_user->membership_level->billing_amount > 0) {
            ?>
                                <li><strong><?php 
            _e("Membership Fee", "pmpro");
            ?>
:</strong>
                                    <?php 
            $level = $current_user->membership_level;
            if ($current_user->membership_level->cycle_number > 1) {
                printf(__('%s every %d %s.', 'pmpro'), pmpro_formatPrice($level->billing_amount), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number));
            } elseif ($current_user->membership_level->cycle_number == 1) {
                printf(__('%s per %s.', 'pmpro'), pmpro_formatPrice($level->billing_amount), pmpro_translate_billing_period($level->cycle_period));
            } else {
                echo pmpro_formatPrice($current_user->membership_level->billing_amount);
            }
            ?>
                                </li>
                            <?php 
        }
        ?>
						

                            <?php 
        if ($current_user->membership_level->billing_limit) {
            ?>
                                <li><strong><?php 
            _e("Duration", "pmpro");
            ?>
:</strong> <?php 
            echo $current_user->membership_level->billing_limit . ' ' . sornot($current_user->membership_level->cycle_period, $current_user->membership_level->billing_limit);
            ?>
</li>
                            <?php 
        }
        ?>

                            <?php 
        if ($current_user->membership_level->enddate) {
            ?>
                                <li><strong><?php 
            _e("Membership Expires", "pmpro");
            ?>
:</strong> <?php 
            echo date_i18n(get_option('date_format'), $current_user->membership_level->enddate);
            ?>
</li>
                            <?php 
        }
        ?>

                            <?php 
        if ($current_user->membership_level->trial_limit == 1) {
            printf(__("Your first payment will cost %s.", "pmpro"), pmpro_formatPrice($current_user->membership_level->trial_amount));
        } elseif (!empty($current_user->membership_level->trial_limit)) {
            printf(__("Your first %d payments will cost %s.", "pmpro"), $current_user->membership_level->trial_limit, pmpro_formatPrice($current_user->membership_level->trial_amount));
        }
        ?>
                        </ul>

                    </div> <!-- end pmpro_account-membership -->

                    <div id="pmpro_account-profile" class="pmpro_box hide">	
                        <?php 
        get_currentuserinfo();
        ?>
 
                        <h3><?php 
        _e("My Account", "pmpro");
        ?>
</h3>
                        <?php 
        if ($current_user->user_firstname) {
            ?>
                            <p><?php 
            echo $current_user->user_firstname;
            ?>
 <?php 
            echo $current_user->user_lastname;
            ?>
</p>
                        <?php 
        }
        ?>
                        <ul>
                            <li><strong><?php 
        _e("Username", "pmpro");
        ?>
:</strong> <?php 
        echo $current_user->user_login;
        ?>
</li>
                            <li><strong><?php 
        _e("Email", "pmpro");
        ?>
:</strong> <?php 
        echo $current_user->user_email;
        ?>
</li>
                        </ul>
                        <p>
                            <a href="<?php 
        echo admin_url('profile.php');
        ?>
"><?php 
        _e("Edit Profile", "pmpro");
        ?>
</a> |
                            <a href="<?php 
        echo admin_url('profile.php');
        ?>
"><?php 
        _ex("Change Password", "As in 'change password'.", "pmpro");
        ?>
</a>
                        </p>
                    </div> <!-- end pmpro_account-profile -->

                    <?php 
        //last invoice for current info
        //$ssorder = $wpdb->get_row("SELECT *, UNIX_TIMESTAMP(timestamp) as timestamp FROM $wpdb->pmpro_membership_orders WHERE user_id = '$current_user->ID' AND membership_id = '" . $current_user->membership_level->ID . "' AND status = 'success' ORDER BY timestamp DESC LIMIT 1");
        $ssorder = new MemberOrder();
        $ssorder->getLastMemberOrder();
        $invoices = $wpdb->get_results("SELECT *, UNIX_TIMESTAMP(timestamp) as timestamp FROM {$wpdb->pmpro_membership_orders} WHERE user_id = '{$current_user->ID}' ORDER BY timestamp DESC LIMIT 6");
        if (!empty($ssorder->id) && $ssorder->gateway != "check" && $ssorder->gateway != "paypalexpress" && $ssorder->gateway != "paypalstandard" && $ssorder->gateway != "twocheckout") {
            //default values from DB (should be last order or last update)
            $bfirstname = get_user_meta($current_user->ID, "pmpro_bfirstname", true);
            $blastname = get_user_meta($current_user->ID, "pmpro_blastname", true);
            $baddress1 = get_user_meta($current_user->ID, "pmpro_baddress1", true);
            $baddress2 = get_user_meta($current_user->ID, "pmpro_baddress2", true);
            $bcity = get_user_meta($current_user->ID, "pmpro_bcity", true);
            $bstate = get_user_meta($current_user->ID, "pmpro_bstate", true);
            $bzipcode = get_user_meta($current_user->ID, "pmpro_bzipcode", true);
            $bcountry = get_user_meta($current_user->ID, "pmpro_bcountry", true);
            $bphone = get_user_meta($current_user->ID, "pmpro_bphone", true);
            $bemail = get_user_meta($current_user->ID, "pmpro_bemail", true);
            $bconfirmemail = get_user_meta($current_user->ID, "pmpro_bconfirmemail", true);
            $CardType = get_user_meta($current_user->ID, "pmpro_CardType", true);
            $AccountNumber = hideCardNumber(get_user_meta($current_user->ID, "pmpro_AccountNumber", true), false);
            $ExpirationMonth = get_user_meta($current_user->ID, "pmpro_ExpirationMonth", true);
            $ExpirationYear = get_user_meta($current_user->ID, "pmpro_ExpirationYear", true);
            ?>
	

                        <div id="pmpro_account-billing" class="pmpro_box">
                            <h3><?php 
            _e("Billing Information", "pmpro");
            ?>
</h3>
                            <?php 
            if (!empty($baddress1)) {
                ?>
                                <p>
                                    <strong><?php 
                _e("Billing Address", "pmpro");
                ?>
</strong><br />
                                    <?php 
                echo $bfirstname . " " . $blastname;
                ?>
                                    <br />		
                                    <?php 
                echo $baddress1;
                ?>
<br />
                                    <?php 
                if ($baddress2) {
                    echo $baddress2 . "<br />";
                }
                ?>
                                    <?php 
                if ($bcity && $bstate) {
                    ?>
                                        <?php 
                    echo $bcity;
                    ?>
, <?php 
                    echo $bstate;
                    ?>
 <?php 
                    echo $bzipcode;
                    ?>
 <?php 
                    echo $bcountry;
                    ?>
                                    <?php 
                }
                ?>
                         
                                    <br />
                                    <?php 
                echo formatPhone($bphone);
                ?>
                                </p>
                            <?php 
            }
            ?>

                            <?php 
            if (!empty($AccountNumber)) {
                ?>
                                <p>
                                    <strong><?php 
                _e("Payment Method", "pmpro");
                ?>
</strong><br />
                                    <?php 
                echo $CardType;
                ?>
: <?php 
                echo last4($AccountNumber);
                ?>
 (<?php 
                echo $ExpirationMonth;
                ?>
/<?php 
                echo $ExpirationYear;
                ?>
)
                                </p>
                            <?php 
            }
            ?>

                            <?php 
            if (isset($ssorder->status) && $ssorder->status == "success" && (isset($ssorder->gateway) && in_array($ssorder->gateway, array("authorizenet", "paypal", "stripe", "braintree", "payflow", "cybersource")))) {
                ?>
                                <p><a href="<?php 
                echo pmpro_url("billing", "");
                ?>
"><?php 
                _e("Edit Billing Information", "pmpro");
                ?>
</a></p>
                                <?php 
            }
            ?>
                        </div> <!-- end pmpro_account-billing -->				
                        <?php 
        }
        ?>

                    <?php 
        if (!empty($invoices)) {
            ?>
                        <div id="pmpro_account-invoices" class="pmpro_box">
                            <h3><?php 
            _e("Past Invoices", "pmpro");
            ?>
</h3>
                            <ul>
                                <?php 
            $count = 0;
            foreach ($invoices as $invoice) {
                if ($count++ > 5) {
                    break;
                }
                ?>
                                    <li><a href="<?php 
                echo pmpro_url("invoice", "?invoice=" . $invoice->code);
                ?>
"><?php 
                echo date_i18n(get_option("date_format"), $invoice->timestamp);
                ?>
 (<?php 
                echo pmpro_formatPrice($invoice->total);
                ?>
)</a></li>
                                    <?php 
            }
            ?>
                            </ul>
                            <?php 
            if ($count == 6) {
                ?>
                                <p><a href="<?php 
                echo pmpro_url("invoice");
                ?>
"><?php 
                _e("View All Invoices", "pmpro");
                ?>
</a></p>
                            <?php 
            }
            ?>
                        </div> <!-- end pmpro_account-billing -->
                    <?php 
        }
        ?>
                    <p class="help-block">We have the following subscriptions available for our site. To join, simply click on the <strong>Renew</strong> or <strong>Change Subscription</strong> button and then complete the registration details.</p>
                    <?php 
        getLevels();
        ?>
                    <div id="pmpro_account-links" class="pmpro_box">
                        <h3><?php 
        _e("Manage Membership", "pmpro");
        ?>
</h3>
                        <ul>
                            <?php 
        do_action("pmpro_member_links_top");
        ?>
                            <?php 
        if (isset($ssorder->status) && $ssorder->status == "success" && (isset($ssorder->gateway) && in_array($ssorder->gateway, array("authorizenet", "paypal", "stripe", "braintree", "payflow", "cybersource")))) {
            ?>
                                <li><a href="<?php 
            echo pmpro_url("billing", "", "https");
            ?>
"><?php 
            _e("Update Billing Information", "pmpro");
            ?>
</a></li>
                            <?php 
        }
        ?>
                            <?php 
        if (count($pmpro_levels) > 1 && !defined("PMPRO_DEFAULT_LEVEL")) {
            ?>
                                <li><a href="<?php 
            echo pmpro_url("levels");
            ?>
"> <?php 
            _e("Change Membership Level", "pmpro");
            ?>
</a></li>
                            <?php 
        }
        ?>
                            <li><a href="<?php 
        echo pmpro_url("cancel");
        ?>
" class="red"><?php 
        _e("Cancel Membership", "pmpro");
        ?>
</a></li>
                            <?php 
        do_action("pmpro_member_links_bottom");
        ?>
                        </ul>
                    </div> <!-- end pmpro_account-links -->		
                </div> <!-- end pmpro_account -->	

                <!-- END CONTENT-->
            </div>
        </div>
        <?php 
    }
    ?>
    <?php 
}