Skip to content

Instantly share code, notes, and snippets.

View ideadude's full-sized avatar

Jason Coleman ideadude

View GitHub Profile
@ideadude
ideadude / my_wp_plugin_check_ignore_directories.php
Created May 27, 2024 21:16
Exclude some extra dirs from the WordPress plugin check plugin.
<?php
/**
* Exclude some extra dirs from the WordPress plugin check plugin.
*/
function my_wp_plugin_check_ignore_directories( $dirs ) {
// For reference, the default dirs as of v1.0.1
// $default_ignore_directories = array(
// '.git',
// 'vendor',
// 'node_modules',
@ideadude
ideadude / my_pmpro_category_filter.php
Last active April 14, 2024 16:18 — forked from strangerstudios/my_pmpro_category_filter.php
Add specific members-only categories back to main loop when filtering searches and archives.
<?php
/**
* Add specific members-only categories back to main loop
* when filtering searches and archives.
* Updated for PMPro 3.0+.
*
* 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/
@ideadude
ideadude / my_pmpro_registration_checks_stop_free_checkouts.php
Created January 13, 2024 16:37
Don't let existing members checkout for a free level. [Paid Memberships Pro]
/**
* Don't let existing members checkout for a free level.
*
* 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/
*/
function my_pmpro_registration_checks_stop_free_checkouts( $okay ) {
global $pmpro_level;
@ideadude
ideadude / cleanlog.sh
Last active January 10, 2024 22:14
Scrub emails out of an access log and note affected emails in scrubbed_text.txt
##
# Clean passwords out of access logs.
# Be sure to update the LOG_FILE line to match the location of your log file.
# This will edit your log files. You can back it up and then delete the backup if this works.
# This will also create a file scrubbed_emails.txt with a list of affected emails.
# This requires that both the password and password2 fields be in the logs.
# If you don't have password2 fields, edit the script to use the field that comes after password in your logs.
##
#!/bin/bash
@ideadude
ideadude / my_pmpro_user_field_swap_to_checkbox_grouped.php
Created December 28, 2023 18:34
Swap a PMPro user field to the checkbox_grouped type.
<?php
/**
* Currently, the PMPro user fields GUI does not allow you to choose
* the checkbox_grouped field type.
*
* These fields can be added via custom code though. If you want to manage some
* aspects of the field in the GUI, you can create a multiselect field,
* then swap it to the checkbox group using this code.
*
* You can add this recipe to your site by creating a custom plugin
@ideadude
ideadude / pmpro_patch_for_affiliate_wp.txt
Created November 5, 2023 14:21
pmpro_patch_for_affiliate_wp
diff --git a/includes/integrations/class-pmp.php b/includes/integrations/class-pmp.php
index 00a1c89..b133e69 100644
--- a/includes/integrations/class-pmp.php
+++ b/includes/integrations/class-pmp.php
@@ -47,8 +47,7 @@ class Affiliate_WP_PMP extends Affiliate_WP_Base {
public function init() {
add_action( 'pmpro_added_order', array( $this, 'add_pending_referral' ), 10 );
- add_action( 'pmpro_updated_order', array( $this, 'mark_referral_complete' ), 10 );
- add_action( 'admin_init', array( $this, 'revoke_referral_on_refund_and_cancel' ), 10);
@ideadude
ideadude / Affiliate_WP_PMP.php
Created November 5, 2023 14:17
Jason Fixed the PMP integration for AffiliateWP 2 years ago and they never updated it. Here's the old code.
<?php
/**
* Integrations: Paid Memberships Pro
*
* @package AffiliateWP
* @subpackage Integrations
* @copyright Copyright (c) 2016, Sandhills Development, LLC
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.8
*/
@ideadude
ideadude / tag_and_delete_inactive_users.php
Created October 28, 2023 16:42
Script to tag and delete inactive users from WP/PMPro.
<?php
/**
* Tag inactive users.
* One time script. To run, visit /?delete_inactive_users=1 as an admin.
* An inactive user:
* - Has no logins within the last 2 years.
* - Has no paid orders.
* - Has no support tickets.
* ? Add inactive taxonomy to users? Then delete users in that taxonomy?
* Get users who are tagged for deletion:
@ideadude
ideadude / unpaidmembers.sql
Created October 28, 2023 16:22
MySQL query to get members with paid levels (6, 20, 21) that don't have a paid order within the past 12 months.
# Find members with active paid memberships but their last order was > 12 months ago.
SELECT
m.user_id,
m.membership_id,
u.user_email,
MAX(o.timestamp) as last_order_timestamp
FROM
wp_pmpro_memberships_users m
LEFT JOIN wp_users u ON m.user_id = u.ID
JOIN
@ideadude
ideadude / class-rate-limter.php
Created May 22, 2023 18:35
Generic IP limiter class for WordPress.
<?php
// Check if this class has already been loaded.
if ( class_exists( 'Rate_Limiter' ) ) {
return;
}
/**
* RateLimiter Class
* Limit the number of times a user can perform an action within a given period of time.
*/