Skip to content

Instantly share code, notes, and snippets.

View kimcoleman's full-sized avatar

Kim Coleman kimcoleman

View GitHub Profile
@kimcoleman
kimcoleman / set_enddate_null.sql
Last active November 30, 2018 18:46 — forked from strangerstudios/set_enddate_null.sql
This SQL query will clear the expiration date for active recurring memberships in Paid Memberships Pro.
# BACKUP FIRST
# This will remove any expiration date on
# every member in your database.
# BACKUP FIRST
UPDATE wp_pmpro_memberships_users
SET enddate = '0000-00-00 00:00:00'
WHERE status = 'active'
@kimcoleman
kimcoleman / my_pmpro_getresponse_custom_fields.php
Last active December 20, 2018 17:03 — forked from strangerstudios/my_pmpro_getresponse_custom_fields.php
Sync user fields with GetResponse with PMPro GetResponse
<?php
/**
* This filter will send additional user meta fields to contacts in GetResponse.
*
* Add this code to your PMPro Customizations Plugin
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*
* @param array $fields the array of fields to send
* @param object $user what is written in the code that we want to change
*/
@kimcoleman
kimcoleman / my_pmpro_authorizenet_post_url.php
Last active April 7, 2021 03:54 — forked from strangerstudios/my_pmpro_authorizenet_post_url.php
Point the Authorize.net integration to a different end point (e.g. to use an Authorize.net mirror API)
<?php
/*
* Point the Authorize.net integration for PMPro to a different end point (e.g. to use an Authorize.net mirror API)
*
*/
function my_pmpro_authorizenet_post_url( $url, $environment ) {
if ($environment == "sandbox") {
$url = 'https://domain.com/path-to-the-sandbox-endpoint/';
} else {
$url = 'https://domain.com/path-to-the-live-endpoint/';
@kimcoleman
kimcoleman / my_pmpro_reports_extras.php
Last active April 16, 2021 01:23 — forked from strangerstudios/my_pmpro_reports_extras
Add a Custom Report to the Memberships > Reports Screen in Paid Memberships Pro.
<?php
/**
* Add a Custom Report to the Memberships > Reports Screen in Paid Memberships Pro.
*
* For each report, add a line like:
* global $pmpro_reports;
* $pmpro_reports['slug'] = 'Title';
*
* For each report, also write two functions:
* pmpro_report_{slug}_widget() to show up on the report homepage.
@kimcoleman
kimcoleman / pmpro_show_spots_available.php
Last active April 12, 2024 06:54 — forked from andrewlimaza/pmpro_show_spots_available.php
Show number of spots available for a membership level Paid Memberships Pro.
<?php
/**
* This will show '0/X spots available.' on membership level if a limit is set from (https://www.paidmembershipspro.com/limit-number-members-membership-level/)
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* For help, post a support thread on www.paidmembershipspro.com
*/
function pmpro_show_spots_available( $expiration_text, $level ) {
global $wpdb;
@kimcoleman
kimcoleman / my_woocommerce_get_price_html.php
Created October 28, 2019 11:48 — forked from messica/my_woocommerce_get_price_html.php
Display membership pricing along with regular pricing.
<?php
// Display membership pricing along with regular pricing.
function my_woocommerce_get_price_html($price, $product) {
// Get all levels.
$all_levels = pmpro_getAllLevels(true, true);
// Get original price.
$reg_price = wc_price($product->get_regular_price());
@kimcoleman
kimcoleman / my_pmprosl_custom_shortcode.php
Last active December 4, 2019 16:18 — forked from LMNTL/my_pmprosl_custom_shortcode.php
Use a custom social login shortcode with PMPro Social Login (Requires v.3 or above)
<?php
/**
* Use a custom shortcode with the Social Login Add On for Paid Memberships Pro (Requires v.3 or above)
*
*/
function my_pmprosl_custom_shortcode( $shortcode ) {
// Edit this line to change the shortcode displayed on the checkout page.
return '[TheChamp-Login title="Use your Social Account to Login"]';
}
add_filter( 'pmprosl_login_shortcode', 'my_pmprosl_custom_shortcode' );
@kimcoleman
kimcoleman / my_pmpro_memberslist_extra_cols.php
Last active December 7, 2019 15:30 — forked from strangerstudios/my_pmpro_memberslist_extra_cols.php
Add a custom column to the Memberships > Members admin page for a user field added via Register Helper using the PMPro hook method.
<?php
/**
* Add a custom column to the Memberships > Members admin page for a user field
* added via Register Helper using the PMPro hook method.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
@kimcoleman
kimcoleman / pmpro-sponsored-members-assign-to-parent.php
Last active June 4, 2024 14:19 — forked from greathmaster/pmpro-sponsored-members-assign-to-parent.php
Retroactively assign a user to a Parent account when using the Sponsored Members Add On.
/**
* Retroactively assign a user to a Parent account when using the Sponsored Members Add On.
* Enter the user ID of parent account in the "Assign to Parent Account" on the "Edit Profile" screen.
*
* Note: The user's active Membership Level must be the correct "Child" level for that Parent/Child relationship.
*
*/
function pmprosm_assign_child_members( $profileuser ) {
if ( function_exists( 'pmprosm_getSponsor' ) && current_user_can( 'edit_users' ) ) {
@kimcoleman
kimcoleman / my_init_pmpro_mini_api.php
Last active April 3, 2021 03:51 — forked from strangerstudios/my_init_pmpro_mini_api.php
Very basic custom RESTful API to check the membership level of a Paid Memberships Pro User
<?php
/**
* Call to http://yoursite.com/[email protected]&secret=SOMESECRETHERE to check the membership level of a user.
*/
function my_init_pmpro_mini_api() {
if ( function_exists( 'pmpro_getMembershipLevelForUser' ) &&
! empty( $_REQUEST[ 'verify' ] ) &&
! empty( $_REQUEST[ 'secret' ] ) )
{
if ( $_REQUEST[ 'secret' ] != 'SOMESECRETHERE' ) {