Skip to content

Instantly share code, notes, and snippets.

View ideadude's full-sized avatar

Jason Coleman ideadude

View GitHub Profile
@ideadude
ideadude / my_pmproll_track_login_spam.php
Created April 5, 2025 18:06
Consider failed login attempts as spam, and if a user is consider a spammer, block them from logging in.
<?php
/**
* We will consider failed login attempts as spam.
* If a user is consider a spammer, block them from logging in.
*
* Some ideas if we merge this into PMPro core:
* - Need documentation RE bypassing the login block.
* - Consider adding settings RE what spammers are blocked from.
* - Consider a way to view/clear the spam activity queue.
* - We know the username they tried to login with,
@ideadude
ideadude / my_init_memory.php
Created March 24, 2025 14:22
Increase memory and execution time for WP admins and crons.
<?php
/**
* Increase memory and execution time for WP admins and crons
* Add this code into a custom plugin or code snippet.
*/
function my_init_memory() {
if( current_user_can( 'manage_options' ) ) {
ini_set( 'max_execution_time', 300 ); //300 seconds = 5 minutes
ini_set( 'memory_limit', '812M' );
} elseif ( wp_doing_cron() ) {
@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: