Skip to content

Instantly share code, notes, and snippets.

View kimcoleman's full-sized avatar

Kim Coleman kimcoleman

View GitHub Profile
@kimcoleman
kimcoleman / my_pmpro_widgets_by_membership_level.php
Last active August 1, 2023 12:42
Hide widgets by widget instance ID and membership level to protect specific widgets for members only.
<?php
/**
* Hide widgets by widget instance ID for protected members only content.
* Update the $hide_widget_instances_array with the array of widget instance IDs you want to filter.
* Update the pmpro_hasMembershipLevel check for your membership level IDs.
*
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_widgets_by_membership_level( $instance, $widget, $args ) {
@kimcoleman
kimcoleman / pmpro_do_membership_account_shortcode.php
Created August 23, 2018 16:21
Show the pmpro_account shortcode on the WooCommmerce My Account page for members who have a history of membership through Paid Memberships Pro.
<?php
/**
* Show the pmpro_account shortcode on the WooCommmerce My Account page for members
* who have a history of membership through Paid Memberships Pro.
*/
function pmpro_do_membership_account_shortcode() {
global $wpdb, $current_user;
if( is_user_logged_in() && defined( 'PMPRO_VERSION' ) ) { ?>
<style> .pmpro_actionlinks {display: none; } </style>
<?php
@kimcoleman
kimcoleman / buddypress-memberlite-search.css
Last active August 30, 2018 12:42
Suggested improvements to make BuddyPress 3.1.0 'Nouveau' members search form display properly in Memberlite 4.0+
<style>
#primary form.bp-dir-search-form {
display: grid;
grid-template-columns: 4fr 1fr;
grid-template-areas: "input button";
}
#primary form.bp-dir-search-form input[type="search"]#dir-members-search {
border: none;
border-radius: 0px;
grid-area: input;
@kimcoleman
kimcoleman / pmpro_content_filter_description_confirmation.php
Last active August 24, 2020 07:22
Apply the WordPress the_content filter to the level description and confirmation message so that you can add shortcodes or other content in this area.
<?php
/**
* Apply the WordPress the_content filter to the level description and confirmation message
* so that you can add shortcodes or other content in this area.
*
* 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 / my_memberlite_google_fonts_weights.php
Created September 13, 2018 17:35
Filter the Google Fonts weights loaded in Memberlite.
<?php // Do not copy this tag
/**
* Filter the Google Font weights loaded in Memberlite (as of version 4.0.1).
*
* Add this code below to a plugin for theme customizations.
*/
function my_memberlite_google_fonts_weights( $font_weights ) {
$font_weights = '300,400,700,900';
return $font_weights;
}
@kimcoleman
kimcoleman / pmpro_monsterinsights_level_custom_dimension.php
Last active May 15, 2023 15:53
Add a new "Membership Level" dimension to track via MonsterInsights.
<?php
/**
* Add a new "Membership Level" Custom Dimension to your Google Analytics tracking code.
*
* Requires Paid Memberships Pro, MonsterInsights Pro and the MonsterInsights - Dimensions Addon.
*/
/**
* Filter for adding the new dimension as under Insights > Settings > Dimensions
*/
@kimcoleman
kimcoleman / unlock_posts_by_ID.php
Created September 24, 2018 16:58
Make specific post IDs in a restricted category available publicly.
<?php // Do not copy this tag
/*
* Make specific post IDs in a restricted category available publicly.
*
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function unlock_posts_by_ID( $hasaccess, $post, $user, $post_membership_levels ) {
// If they already have access, let them at it.
if ( $hasaccess ) {
return $hasaccess;
@kimcoleman
kimcoleman / donteatthat_pmpro_checkout_level.php
Last active October 19, 2018 10:51 — forked from strangerstudios/my_pmpro_checkout_level.php
PMPro Register Helper Customizations for donteatthat Thread
<?php
/**
* Custom Register Helper fields for donteatthat thread on price-adjusting fields.
*/
function donteatthat_pmprorh_init() {
// Don't break if Register Helper is not loaded.
if ( ! function_exists( 'pmprorh_add_registration_field' ) ) {
return false;
}
@kimcoleman
kimcoleman / pmpro-sitewide-sale-neon-template-demo.php
Last active November 1, 2018 18:11
Demo content for the "Neon" template example of Sitewide Sale Add On for Paid Memberships Pro
<?php
/*
* This is demo content for the Sitewide Sale Add On for Paid Memberships Pro.
* You can view a live preview of this content in the "Neon" Sale Template here:
* https://demo.memberlitetheme.com/membership/sitewide-sales/sample-sale-2/
*/
?>
<div class="text-center">
<h1>Join the ACME Podcast</h1>
<h2>Black Friday</h2>
@kimcoleman
kimcoleman / pmpro-sitewide-sale-gradient-template-demo.php
Created November 1, 2018 18:11
Demo content for the "Gradient" template example of Sitewide Sale Add On for Paid Memberships Pro
<?php
/*
* This is demo content for the Sitewide Sale Add On for Paid Memberships Pro.
* You can view a live preview of this content in the "Gradient" Sale Template here:
* https://demo.memberlitetheme.com/membership/sitewide-sales/sample-sale-1/
*
* Remove this comment and place the content below into the "Sale Content" field of your Sitewide Sale.
*/
?>
[fa icon="piggy-bank"]