Skip to content

Instantly share code, notes, and snippets.

Kim Coleman kimcoleman

Block or report user

Report or block kimcoleman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kimcoleman
kimcoleman / show_disallowed_level_names_content_filter.php
Created Jun 6, 2019
Reveal the level name for a disallowed level in the PMPro content message on restricted content.
View show_disallowed_level_names_content_filter.php
<?php
/**
* Reveal the level name for a disallowed level in the PMPro content message on restricted content.
*
*/
function show_disallowed_level_names_content_filter( $r, $post_membership_levels_ids, $post_membership_levels_names ) {
return true;
}
add_filter( 'pmpro_membership_content_filter_disallowed_levels', 'show_disallowed_level_names_content_filter', 10, 3 );
@kimcoleman
kimcoleman / hidden_level_content_pmpro_text_filter.php
Created Jun 6, 2019
Show a unique message on content restricted for a hidden membership level.
View hidden_level_content_pmpro_text_filter.php
<?php
/**
* Show a unique message on content restricted for a hidden membership level.
*
*/
function hidden_level_content_pmpro_text_filter( $text ) {
global $post;
$access = pmpro_has_membership_access( $post->ID, NULL, true );
$level_ids = $access[1];
@kimcoleman
kimcoleman / my_pmpro_reports_extras.php
Last active Jun 4, 2019 — forked from strangerstudios/my_pmpro_reports_extras
Add a Custom Report to the Memberships > Reports Screen in Paid Memberships Pro.
View my_pmpro_reports_extras.php
<?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 / pmproc_create_random_orders.php
Created May 29, 2019
Create random orders across a time period for all active members on your site. Useful for demos.
View pmproc_create_random_orders.php
/**
* Create random orders for all members.
* visit /wp-admin/?create_random_orders=1 to generate orders, then remove this code
* Warning, this can time out or slow your server if you have many members or a long timeframe.
*/
function pmproc_create_random_orders() {
global $wpdb;
if ( empty( $_REQUEST['create_random_orders'] ) ) {
return;
@kimcoleman
kimcoleman / hide_gallery_events_filter_post_types.php
Last active Jun 3, 2019
Hide the 'gallery' CPT from searches and archives if membership is required to access.
View hide_gallery_events_filter_post_types.php
<?php
/**
* Hide the 'gallery' CPT from searches and archives if membership is required to access.
*
*/
function hide_gallery_events_filter_post_types( $post_types ) {
$post_types[] = 'gallery';
return $post_types;
}
add_filter( 'pmpro_search_filter_post_types', 'hide_gallery_events_filter_post_types' );
@kimcoleman
kimcoleman / hide_post_thumbnail_on_restricted_content.php
Last active May 27, 2019
Do not return the post thumbnail (featured image) on restricted content when viewed by a non-member.
View hide_post_thumbnail_on_restricted_content.php
<?php
/**
* Do not return the post thumbnail (featured image) on restricted content when viewed by a non-member.
*
*/
function hide_post_thumbnail_on_restricted_content( $html, $post_id, $post_image_id ) {
if ( function_exists( 'pmpro_has_membership_access' ) ) {
// Check if the user has access to the post.
$hasaccess = pmpro_has_membership_access( $post_id );
@kimcoleman
kimcoleman / my_pmpro_email_custom_login_link_text.php
Created May 17, 2019
Modify the text of the login link in all membership checkout confirmation emails.
View my_pmpro_email_custom_login_link_text.php
@kimcoleman
kimcoleman / custom_css_discount_code_cost_text.css
Created May 15, 2019
Custom css for discount code cost text to avoid class jumbling.
View custom_css_discount_code_cost_text.css
<span class="pricecustomtext">
<span class="standardcoupon">
<span class="pricediscount">
<span class="pricediscounttitle">62% OFF!</span>
<span class="pricediscountcoupon">Groupon Deal</span>
</span><br>
<span class="pricetotal"><span class="priceoriginal">$32</span>$12</span>
<span class="pricerenewal">Renews in 3 months at $32/quarter.<br> Cancel anytime.</span>
</span>
</span>
@kimcoleman
kimcoleman / free_level_change_pmpro_level_cost_text.php
Last active May 2, 2019
Remove or change the level cost for free levels.
View free_level_change_pmpro_level_cost_text.php
<?php
/**
* Remove or change the level cost for free levels.
*/
function free_level_change_pmpro_level_cost_text( $text, $level ) {
if ( pmpro_isLevelFree( $level ) ) {
return '';
} else {
return $text;
}
@kimcoleman
kimcoleman / restrict_posts_level_2.sql
Last active May 1, 2019
Example SQL to add restriction to all 'posts' for Level ID 2. Change level ID for your needs.
View restrict_posts_level_2.sql
#Example SQL to add restriction to all 'posts' for Level ID 2. Change level ID for your needs.
INSERT IGNORE INTO wp_pmpro_memberships_pages (membership_id, page_id)
SELECT 2, ID FROM wp_posts WHERE post_type = 'post';
You can’t perform that action at this time.