Skip to content

Instantly share code, notes, and snippets.

View LMNTL's full-sized avatar

Jessica Thomas LMNTL

  • Chicago, IL
View GitHub Profile
function my_custom_memberslist_order($sqlQuery)
{
echo "<a href=".admin_url('admin.php?page=pmpro-memberslist&enddate_sort=asc').">Sort by Enddate ASC</a><br>".
"<a href=".admin_url('admin.php?page=pmpro-memberslist&enddate_sort=desc').">Sort by Enddate DESC</a>";
if(isset($_REQUEST['enddate_sort']) && ($_REQUEST['enddate_sort'] == 'asc' || $_REQUEST['enddate_sort'] == 'desc'))
{
$sort_order = $_REQUEST['enddate_sort'];
global $wpdb;
@LMNTL
LMNTL / 2checkout_short_signup.php
Created May 16, 2019 20:01
Use the short version of the 2Checkout signup form when checking out with PMPro.
/*
Use the short version of the 2Checkout signup form when checking out.
After installing and activating this, you'll also need to enable "SHORT_FORM" in your 2Checkout settings.
See: https://knowledgecenter.2checkout.com/Documentation/05Ordering/10Minimize_required_checkout_data
*/
function my_pmpro_twocheckout_short_billing( $request_array ) {
$short_form = array(
"SHORT_FORM" => "1"
);
return array_merge( $short_form, $request_array );
@LMNTL
LMNTL / my_pmpro_js_on_submit.php
Created May 17, 2019 17:21
example of adding Javascript to run after the checkout button is clicked with PMPro
// example of adding Javascript to run after the checkout button is clicked
function my_pmpro_js_on_submit() {
?>
<script>
jQuery(document).ready( function(){
jQuery("#pmpro_form").submit( function(){
alert("hello world!");
});
});
</script>
@LMNTL
LMNTL / pmpro-add-role-custom-roles.php
Last active May 20, 2019 18:44 — forked from strangerstudios/pmpro-change-role-custom-roles.php
Add a custom role for new PMPro members at checkout. Add this code to your active theme's functions.php or a custom plugin. - based on https://gist.github.com/strangerstudios/7280471
<?php
/*
This code assumes you already have a 'myrole' custom role created.
Members signing up get the 'myrole' role in addition to any other roles they already have.
Members cancelling are given the subscriber role.
Admin users are ignored.
Usable with or without the PMPro Roles Add On.
*/
function my_pmpro_after_change_membership_level($level_id, $user_id)
{
@LMNTL
LMNTL / my_pmpro_change_email_link_styling.php
Last active May 21, 2019 22:03
customize the HTML/styling of links in PMPro-generated emails
@LMNTL
LMNTL / my_pmproec_pmpro_after_change_membership_level.php
Created May 22, 2019 18:35 — forked from messica/my_pmproec_pmpro_after_change_membership_level.php
Make PMPro MailChimp compatible with PMPro Email Confirmation
<?php
/**
* Make PMPro MailChimp compatible with PMPro Email Confirmation
*/
// Don't subscribe to MailChimp if user is not validated.
function my_pmproec_pmpro_after_change_membership_level($level_id, $user_id) {
if( function_exists('pmproec_isEmailConfirmationLevel') && pmproec_isEmailConfirmationLevel($level_id) ) {
$validation_key = get_user_meta($user_id, "pmpro_email_confirmation_key", true);
@LMNTL
LMNTL / my_pmpro_email_membership_cost
Last active May 24, 2019 23:43
// change !!membership_cost!! email variable to refer to current level cost, only when checking out with paypal
// change !!membership_cost!! email variable to refer to current level cost, only when checking out with paypal
function my_pmpro_email_membership_cost( $data, $email ) {
global $pmpro_levels;
// are we on the paypal ipnhandler page? if not, stop
if( !isset( $_SERVER["REQUEST_URI"] ) || ( strpos( $_SERVER["REQUEST_URI"], "/admin-ajax.php?action=ipnhandler" ) === false ))
return $data;
$level_id = $data['membership_id'];
$current_level = $pmpro_levels[$level_id];
$data['membership_cost'] = pmpro_getLevelCost( $current_level );
/*
Restrict membership access based on parent category
*/
function category_restrictions($hasaccess, $mypost, $myuser, $post_membership_levels)
{
global $post, $current_user;
$categories = wp_get_post_categories($mypost->ID);
$restrict = false;
@LMNTL
LMNTL / pmprosm_additional_account_pages.php
Created May 31, 2019 02:53
Show sponsored seats on the main account page in PMPro settings and other selected pages that contain the [pmpro_account] shortcode.
/*
Show sponsored seats on the account page in PMPro settings and on other selected pages.
Useful for multi-language sites that have different account pages per language.
Requires PMPro and Sponsored Seats Add On.
*/
function my_pmprosm_the_content_account_page($content)
{
global $post, $pmpro_pages, $current_user, $wpdb;
/*
@LMNTL
LMNTL / pmprosm_discount_code.php
Created June 3, 2019 19:54
Example of using the 'discount_code' attribute to change expiration date for PMPro Sponsored Members
/*
Override the discount code given to sponsored members.
This recipe makes any sponsored members with level 2 expire in 2 days.
The 'discount_code' array supports the following attributes:
code_id, level_id, initial_payment, billing_amount, cycle_number, cycle_period, billing_limit,
trial_amount, trial_limit, expiration_number, expiration_period
Make sure that strings in the _period values are wrapped in single quotes, e.g. 'expiration_period' => "'Year'"
*/