Skip to content

Instantly share code, notes, and snippets.

View pbrocks's full-sized avatar

Paul Barthmaier pbrocks

View GitHub Profile
@pbrocks
pbrocks / pmpro-billing-fields-to-profile.php
Last active August 3, 2021 06:21
Add the billing fields created by Paid Memberships Pro to your user Profile for easy editing and inclusion in the Members List CSV.
<?php
/**
* Plugin Name: PMPro Customizations 2 - Billing to Profile
*
* Add PMPro billing fields to the edit user profile page.
*
* You must have installed both Paid Memberships Pro and the Register Helper plugins
*
* https://github.com/strangerstudios/pmpro-register-helper
*/
@pbrocks
pbrocks / pmpro-eu-dkk-format.php
Last active October 9, 2018 15:21 — forked from travislima/pmpro_eu_dkk_format.php
Change EU Danish Krone currency format for Paid Memberships Pro.
<?php // do not include in Customizations plugin if copying and pasting
/**
* Plugin Name: Add a Currency to global
*
* This code gist illustrates a way to customize the format of how your currency displays.
*
* In this example, we will change the PMPro Danish Krone currency
*
* from DKK 1,495.00
* to DKK 1 495,00
@pbrocks
pbrocks / pmpro-memberlite-programmatic-plugin-card.php
Created October 7, 2018 23:20
Get PMPro plugin info programmatically for Memberlite Guide
<?php
$shortcodes_slug = 'memberlite-shortcodes';
$shortcodes_file = WP_PLUGIN_DIR . "/$shortcodes_slug/$shortcodes_slug.php";
$shortcodes_info = get_plugin_data( $shortcodes_file );
?>
<div class="plugin-card plugin-card-<?php echo $shortcodes_slug; ?>">
<div class="plugin-card-top">
<div class="name column-name">
<h3>
<a href="<?php echo $shortcodes_info['PluginURI']; ?>" target="_blank">
@pbrocks
pbrocks / move-something.js
Last active October 11, 2018 05:47
Use jQuery to move a Register Helper field on the Checkout page.
jQuery(document).ready(function($){
$('#pmpro_county_div').appendTo($('#bzipcode').parent());
$('#pmpro_checkout_box-checkout_boxes').css('display','none');
});
@pbrocks
pbrocks / pmpro-redirect-during-checkout.php
Last active July 8, 2021 16:27
An example of how to use `pmpro_checkout_level` to redirect and interject communication with users during checkout. Sample taken from an attempt to prevent downgrading.
<?php // Do not include in Customizations plugin
/**
* pmpro_checkout_level Use `pmpro_checkout_level` to redirect and interject communication with users during checkout.
*
* @param array $levels The array created in admin
*
* @return array Output of the array
*/
function pmpro_redirect_during_checkout( $level ) {
// Check to see if the current user is downgrading (Gold to Silver or Gold to Free)
@pbrocks
pbrocks / pmpro-adjusting-levels-array.php
Created September 30, 2018 17:22
The `pmpro_levels_array` gives you the opportunity to adjust how your Levels array winds up being output to screen.
<?php // Do not include in Customizations plugin
/**
* pmpro_levels_array This filter allows us to alter what winds up as the Levels array
*
* @param array $levels The array created in admin
*
* @return array Output of the array
*/
function adjusting_the_pmpro_levels_array( $levels ) {
$newlevels = array();
@pbrocks
pbrocks / pmpro-level-selection-popup.php
Created September 21, 2018 21:06
PMPro Level selection popup shortcode
<?php // do no include in Customizaations Plugin
/**
* Plugin Name: PMPro Levels Popup
* Description: Add Level selection to a popup
*/
add_shortcode( 'pmpro-levels2-popup', 'pmpro_levels_select_shortcode2' );
function pmpro_levels_select_shortcode2() {
global $wpdb, $pmpro_msg, $pmpro_msgt, $current_user;
@pbrocks
pbrocks / pmpro-admin-only-profile-edit.php
Created September 21, 2018 17:54
Add to customizations plugin, not including the top 4 lines, or create a folder in your plugins directory and add this file, then activate the plugin in your dashboard.
<?php
/**
* Plugin Name: PMPro Admin Only Member Directory Profile
* Description: Remove area in profile with checkbox to show profile in PMPro Directory, and add back the functionality only for administrators.
*/
add_action( 'init', 'pmpromd_remove_profile_field_action' );
function pmpromd_remove_profile_field_action() {
remove_action( 'show_user_profile', 'pmpromd_show_extra_profile_fields' );
remove_action( 'edit_user_profile', 'pmpromd_show_extra_profile_fields' );
@pbrocks
pbrocks / my-pmpro-pages-custom-template-path.php
Last active September 19, 2018 21:29 — forked from strangerstudios/my_pmpro_pages_custom_template_path.php
Tell PMPro to look in the pages folder of this plugin for PMPro page templates.
<?php
/**
* Tell PMPro to look in the pages directory of this plugin for PMPro page templates.
*
* Add this code to your Customizations plugin.
*
* Make sure that there is a /paid-memberships-pro/pages/ directory in the plugin directory with your templates in it.
*/
function my_pmpro_pages_custom_template_path( $default_templates ) {
$default_templates[] = dirname( __FILE__ ) . '/paid-memberships-pro/pages/checkout.php';
@pbrocks
pbrocks / pmpro-set-enddate-null.sql
Last active September 19, 2018 18:05 — forked from strangerstudios/set_enddate_null.sql
This SQL query will clear the expiration date for active recurring memberships in Paid Memberships Pro (PMPro).
# BACKUP FIRST
# You generally do not want to setup PMPro levels
# with both a recurring billing amount AND
# an expiration date.
# This SQL query will clear the expiration date
# for active recurring memberships.
# BACKUP FIRST
UPDATE wp_pmpro_memberships_users
SET enddate = '0000-00-00 00:00:00'
WHERE status = 'active'