Skip to content

Instantly share code, notes, and snippets.

View pbrocks's full-sized avatar

Paul Barthmaier pbrocks

View GitHub Profile
@pbrocks
pbrocks / pmpro-add-company-to-memberslist.php
Created August 31, 2018 20:00
Add Company information from usermeta to PMPro Memberslist
<?php
/**
* Add Company information from usermeta to PMPro Memberslist
*
*/
// Add 'Company' Column to Members List Header
add_action( 'pmpro_memberslist_extra_cols_header', 'pmpro_add_company_to_memberslist_header' );
// Add 'Company' Column to Members List Rows
@pbrocks
pbrocks / pmpro-set-bbpress-role.php
Last active November 7, 2024 04:00
Add a dropdown for bbPress role to PMPro's Add a Member screen
<?php
/**
* Adds dropdown for bbPress user role with Moderator and Participant as options
*/
add_action( 'pmpro_add_member_fields', 'add_bbpress_role_to_add_member' );
add_action( 'pmpro_add_member_added', 'pmpro_add_forum_role', 11 );
function add_bbpress_role_to_add_member( $profileuser ) {
global $wp_roles;
@pbrocks
pbrocks / pmpro_isOrderRecurring.php
Created August 23, 2018 19:16 — forked from strangerstudios/pmpro_isOrderRecurring.php
Perform an action on Paid Memberships Pro (PMPro) recurring orders only.
/*
Perform an action on PMPro recurring orders only.
A recurring order here is one that
(1) Has an earlier order with the same subscription_transaction_id.
(2) Is not created at PMPro checkout.
Note that we are checking if function_exists for pmpro_isOrderRecurring incase
we add this to PMPro core. Also note that the $test_checkout param there is used
here to avoid #2 above. So this parameter will check if the currently running PHP
script is being fired at checkout, not necessarily if the order was created at checkout,
@pbrocks
pbrocks / pmpro-primer-levels-sample.php
Created August 23, 2018 00:02
Build a dashboard menu with a help tab to see different ways to get levels using Paid Memberships Pro.
<?php // Don't include in Customizations plugin
/**
* Plugin Name: PMPro Primer
* Description: A dashboard menu, `pmpro_primer_page`, with some helpful PMPro functions.
* Author: pbrocks
* Version: 1.0.1
* Text-Domain: pmpro-primer-menu
*/
/**
* Add a page to the primer menu.
@pbrocks
pbrocks / pmpro-checkout-page-diagnostic.php
Last active August 22, 2018 18:12
A checkout page diagnostic to see how to change the text of what Paid Memberships Pro produces and also highlights each of the areas where special actions can be run to insert text or other dynamic information.
<?php // if placed in Customizations plugin, do not include this line.
/**
* This is a Checkout page diagnostic to see how to change the text of what
* Paid Memberships Pro produces and also highlights each of the areas where
* special actions can be run to insert text or other dynamic information.
*/
/**
* Plugin Name: Checkout Page Text Changes
*
@pbrocks
pbrocks / pmpro-cancel-after-subscription.php
Created August 15, 2018 20:33
Since PMPro doesn't set the expiration date to allow for recurring billing, set cancellation date to match next payment date.
<?php // do not include in customizations plugin
/**
*
* Change cancellation date to match next payment
*
* Add to PMPro Customizations plugin
*/
add_action( 'pmpro_after_change_membership_level', 'pmpro_cancel_at_end_of_period', 10, 2 );
add_filter( 'pmpro_email_body', 'pmpro_email_body_for_cancel_msg', 10, 2 );
@pbrocks
pbrocks / wp-auto-installer.js
Created August 14, 2018 23:25 — forked from mohandere/wp-auto-installer.js
Wordpress auto installer script PHP
;(function($){
/*
Script Name: WP Auto Installer
Author: Mohan Dere
Version: 1.0
Description : This script install new wordpress setup, create database with tables with content & run search replace database for new urls.
Last Update: 13 Mar 15
*/
@pbrocks
pbrocks / my-pmpro-additional-categories.php
Last active December 19, 2024 06:19 — forked from strangerstudios/my_pmpro_additional_categories.php
Add "Purchase Additional Access" box to Membership Checkout for a la carte category purchase.
<?php // Do not include this line in your Customizations plugin
/**
* Require specific category user meta to view posts in designated categories.
* Custom price-adjusting fields are added via PMPro Register Helper add on (required).
* Add all of this code to your active theme's functions.php or a custom plugin.
*/
add_filter( 'pmpro_has_membership_access_filter', 'my_pmpro_additional_categories', 10, 4 );
function my_pmpro_additional_categories( $hasaccess, $thepost, $theuser, $post_membership_levels ) {
global $wpdb;
@pbrocks
pbrocks / pmpro-after-expiration-change-membership-levels-adjusted.php
Last active May 31, 2021 05:54
Change PMPro membership level upon expiration or cancellation to different respective levels based on member's previous level.
<?php // do not copy to Customizations plugin
/**
* After expiration, assign them a specific "cancelled" level.
*
* Can be used to downgrade someone to a free level when they cancel.
* Will allow members to the "cancel level" to cancel from that though.
*/
function pmpro_upon_expiration_change_membership_levels( $level_id, $user_id ) {
// set this to the id of the original level
$last_level_2 = 2;
@pbrocks
pbrocks / replace-spaces-with-underscores.php
Last active April 8, 2021 20:30 — forked from travislima/replace_spaces_with_underscores.php
Convert capital letters to lowercase and replace spaces with underscores "_" in order to standardize usernames.
<?php // Do not copy this tag.
/**
* Convert capital letters to lowercase and replace all spaces with an underscore when
* new users register for Paid Memberships Pro.
* Add this code to your PMPro Customizations Plugin -
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_custom_user_registration_changes( $userdata ) {