Skip to content

Instantly share code, notes, and snippets.

View kimcoleman's full-sized avatar

Kim Coleman kimcoleman

View GitHub Profile
@kimcoleman
kimcoleman / pmpromd_hide_from_directory_checkout_field.php
Last active June 21, 2021 18:21
This code will add a "Exclude my profile from the member directory" field at membership checkout.
<?php
/**
* This code will add a "Exclude my profile from the member directory" field at membership checkout.
*
* Requires: Member Directory and Profile Pages Add On - https://www.paidmembershipspro.com/add-ons/pmpro-member-directory/
* Requires: Register Helper Add On - https://www.paidmembershipspro.com/add-ons/pmpro-register-helper-add-checkout-and-profile-fields/
*
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Note: When adding to your Customizations Plugin, be careful not to include the opening php tag on line 1 above.
*/
@kimcoleman
kimcoleman / pmpro_hide_acf_fields.php
Last active April 8, 2021 22:08
This code will filter ACF fields added to custom templates using the post's membership requirements.
<?php
/**
* pmpro_hide_acf_fields This code will filter ACF fields added to custom templates using the post's membership requirements.
*
* Add this code to your PMPro Customizations Plugin
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*
* https://www.advancedcustomfields.com/resources/acf-format_value/
*
* @param mixed $value Value which was loaded from the database
@kimcoleman
kimcoleman / pmpro_hide_acf_fields_pmpro_hasMembershipLevel.php
Created June 19, 2018 18:22
Display Advanced Custom Fields for Levels 1 and 2 only.
// Display Advanced Custom Fields for Levels 1 and 2 only.
if ( function_exists( 'get_field' ) && function_exists( 'pmpro_hasMembershipLevel' ) ) {
if( pmpro_hasMembershipLevel( array('1', '2' ) ) ) {
if ( get_field( 'test_field_1' ) ) {
the_field( 'test_field_1' );
}
if ( get_field( 'test_field_2' ) ) {
the_field( 'test_field_2' );
}
@kimcoleman
kimcoleman / pmpro_hide_acf_fields_ pmpro_has_membership_access.php
Created June 19, 2018 18:28
Display Advanced Custom Fields based on the post's membership requirements.
$post = get_queried_object();
if ( function_exists( 'pmpro_has_membership_access' ) ) {
// Check if the user has access to the post.
$hasaccess = pmpro_has_membership_access( $post->ID );
// Display Advanced Custom Fields if the user has access to the post.
if( ! empty( $hasaccess ) && function_exists( 'get_field' ) ) {
@kimcoleman
kimcoleman / my_pmpro_member_badge_display.php
Last active May 24, 2024 15:23
This code will display the member badge on the BuddyPress Profile page using the bp_before_member_header_meta hook.
<?php
/**
* my_pmpro_member_badge_display This code will display the member badge on the BuddyPress Profile page using the bp_before_member_header_meta hook.
*
* Add this code to your PMPro Customizations Plugin
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*
*/
function my_pmpro_member_badge_display( ) {
if ( function_exists( 'pmpromb_show_badge' ) && function_exists( 'pmpro_hasMembershipLevel' ) ) {
@kimcoleman
kimcoleman / pmpro_disable_series_new_content_email.php
Created June 28, 2018 12:45
The gist below disables the user notification sent by the Series Add On for Paid Memberships Pro.
<?php
/**
* pmpro_disable_series_new_content_email The gist below disables the user notification sent by the Series Add On for Paid Memberships Pro.
*
* Add this code to your PMPro Customizations Plugin
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*
*/
function pmpro_disable_series_new_content_email( $recipient, $email ) {
if( $email->template == 'new_content' ) {
@kimcoleman
kimcoleman / pmpro_user_last_order_refunded_check.php
Last active April 7, 2021 04:03
The gist below will stop a user from signing up if their last PMPro order on record was refunded.
<?php
/**
* pmpro_user_last_order_refunded_check The gist below will stop a user from signing up if their last PMPro order on record was refunded.
*
* Add this code to your PMPro Customizations Plugin
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*
*/
function pmpro_user_last_order_refunded_check( $okay ) {
@kimcoleman
kimcoleman / pmpro_user_any_order_refunded_check.php
Last active April 7, 2021 04:03
The gist below will stop a user from signing up if they have ever had a PMPro order refunded.
<?php
/**
* pmpro_user_any_order_refunded_check The gist below will stop a user from signing up if they have ever had a PMPro order refunded.
*
* Add this code to your PMPro Customizations Plugin
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*
*/
function pmpro_user_any_order_refunded_check( $okay ) {
@kimcoleman
kimcoleman / pmpro_user_any_order_refunded_last_success_check.php
Created July 13, 2018 12:33
The gist below will stop a user from signing up if they have ever had a PMPro order refunded unless their last order was success.
<?php
/**
* pmpro_user_any_order_refunded_last_success_check The gist below will stop a user from signing up if they have ever
* had a PMPro order refunded unless their last order was success.
*
* Add this code to your PMPro Customizations Plugin
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*
*/
function pmpro_user_any_order_refunded_last_success_check( $okay ) {
@kimcoleman
kimcoleman / beaver_builder_compatibility_for_pmpro.php
Created July 21, 2018 11:36
Ensure Paid Memberships Pro compatibility when using Beaver Builder.
<?php //Do not copy this PHP tag into your code.
/**
* Ensure Paid Memberships Pro compatibility when using Beaver Builder:
* https://wordpress.org/plugins/beaver-builder-lite-version/
*
* Your administrator-level account must have a Membership Level in order to edit all of the pages assigned
* under Memberships > Pages.
*
* You must also set a Custom Field on the Membership Checkout page with the key 'pmpro_default_level' and
* value of a level ID in order to properly edit your Membership Checkout page using Beaver Builder.