Skip to content

Instantly share code, notes, and snippets.

View ideadude's full-sized avatar

Jason Coleman ideadude

View GitHub Profile
@ideadude
ideadude / my_unescaped_pmpro_tos_content.php
Created February 21, 2023 15:18
Update the TOS on the PMPro checkout page to skip the escaping introduced in PMPro 2.10.
<?php
/**
* Update the TOS on the PMPro checkout page to skip the escaping
* introduced in PMPro 2.10. This will work in PMPro 2.10.1 or higher.
*
* You can add this code to your site using the Code Snippets plugin or by
* placing the code into a custom plugin or your theme's functions.php.
*/
function my_unescaped_pmpro_tos_content( $content, $tospage ) {
return do_shortcode( $tospage->post_content );
@ideadude
ideadude / my_login_redirect.php
Created February 9, 2023 19:24
Redirect all WordPress users to a very specific page on login.
<?php
/**
* Redirect all users to a very specific page on login.
* This should work no matter what login form/etc you are using.
* If it doesn't work, maybe the 999 priority needs to be higher.
* If you want to respect the redirect_to param or earlier callbacks
* that overwrite it, uncomment the section at the top of the function.
*
* You can add this code to your site using the Code Snippets plugin or by
* placing the code into a custom plugin or your theme's functions.php.
@ideadude
ideadude / my_upload_size_limit_for_non_admins.php
Created December 9, 2022 15:46
Limit non-admin/editor file uploads to 2mb with WordPress
<?php
/**
* Limit non-admin/editor file uploads to 2mb
* We check the upload_files capability,
* so anyone with access to the Media Library
* can upload files at the PHP/server set max.
*
* 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.
@ideadude
ideadude / my_pmprosp_minimum_password_score_message.php
Created December 5, 2022 21:53
Translate the password suggestions in the PMPro Strong Passwords Add On
<?php
/**
* Swap or translate the password suggestions from the PMPro Strong Password Add On.
* These suggestions come from the bundled password strenght library.
* Until we update the plugin to make these translatable,
* the following code can be used to translate them on your site.
*
* 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.
@ideadude
ideadude / fix-charset-for-pmpro-tables.sql
Created October 21, 2022 13:50
Update some PMPro DB tables to use UTF8 character sets.
# PMPro doesn't set the character set when creating its tables.
# So on install PMPro will use the default character set for your DB.
# In some cases this might be something like latin1, which will not
# work with special characters for non-latin languages, e.g. Hebrew.
# To fix this, you can update the character set on these tables using MySQL.
#
# IMPORTANT: Back up your DB (at least these tables) before running any queries.
ALTER TABLE wp_pmpro_membership_levels CONVERT TO CHARACTER SET utf8;
ALTER TABLE wp_pmpro_membership_levelmeta CONVERT TO CHARACTER SET utf8;
ALTER TABLE wp_pmpro_membership_ordermeta CONVERT TO CHARACTER SET utf8;
@ideadude
ideadude / my_pmpro_additional_categories.php
Created October 19, 2022 09:59 — forked from strangerstudios/my_pmpro_additional_categories.php
Add "Purchase Additional Access" box to Membership Checkout for a la carte category purchase.
<?php
/**
* Require specific category user meta to view posts in designated categories.
* Custom price-adjusting fields are added via user fields.
* The initial payment and billing amount is adjusted based on cat selections.
*
* 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_email_custom_data.php
Created October 12, 2022 19:04
Add user_id as a data variable for email templates in PMPro
<?php
/* This code will add user_id as a data variable for email templates in PMPro.
*
* 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/
*/
// begin copying code below here
@ideadude
ideadude / PMPro_Membership_Level.php
Created September 30, 2022 18:53
Some example code of how to create a PMPro membership level.
<?php
/**
* Some example code of how to create a PMPro membership level.
* Uses the PMPro_Membership_Level class and save() method.
*/
// Copy a level.
$level = new PMPro_Membership_Level( 1 ); // Pass the ID of the level to copy.
$level->id = $level->ID = null; // Clear out the ID, triggers insert on save.
$level->name = 'NewName'; // Update any property you want.
@ideadude
ideadude / non_featured_images_query.sql
Created September 20, 2022 19:12
SQL Query to find images (and other attachments) that aren't being used as featured images.
@ideadude
ideadude / add-billing-to-add-member-and-profile.php
Last active August 25, 2022 17:31 — forked from andrewlimaza/add-billing-to-add-member-and-profile.php
Add billing fields to Add Member Settings
<?php
/*
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* This will add billing fields to Add Member and the user's profile page.
*/
function add_billing_fields_to_add_member_profile() {
//check for register helper
if(!function_exists("pmpro_add_user_field")) // pmprorh_add_registration_field
return;