Skip to content

Instantly share code, notes, and snippets.

View ipokkel's full-sized avatar

Theuns Coetzee ipokkel

View GitHub Profile
@andrewlimaza
andrewlimaza / load-legacy-pmpro-content-message.php
Last active August 19, 2024 06:49
Add the option to load legacy content message.
<?php
/**
* Run this code _once_ and then remove it from your site. To run this code visit any page of the admin area.
* After visiting any admin page, you may delete this script from your site.
* This will add legacy logic to the content message for non-members.
*/
function my_pmpro_legacy_content_message() {
// Only logged-in admins can run this.
if ( ! current_user_can( 'manage_options' ) || ! empty( get_option( 'pmpro_nonmembertext' ) ) ) {
return;
@dwanjuki
dwanjuki / my_pmpro_pbc_order_added_admin_email.php
Created June 21, 2024 09:27
Send admin an email notification on Pay By Check pending order creation
<?php
/**
* Send admin an email notification on Pay By Check pending order creation
*
* 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 / export_woocommerce_subscription_user_data.txt
Created August 7, 2023 17:38
MySQL command to export WooCommerce subscription data, including User ID, Product, and Next Payment Date
SELECT
p.ID as 'Subscription ID',
pm1.meta_value as 'User ID',
oitems.order_item_name as 'Product',
pm2.meta_value as 'Next Payment Date'
FROM wp_posts p
INNER JOIN wp_postmeta pm1 ON pm1.post_id = p.ID
INNER JOIN wp_postmeta pm2 ON pm2.post_id = p.ID
INNER JOIN wp_woocommerce_order_items oitems ON oitems.order_id = p.ID
WHERE
@dwanjuki
dwanjuki / my_pmproal_allow_html_tags.php
Last active June 13, 2023 14:32
Example to allow use of additional HTML tags in the Advanced Levels Shortcode
<?php
/*
* Example to allow use of additional HTML tags in the Advanced Levels Shortcode
*
* This example will allow H1 tags, class attributes on H1 tags, and H2 tags
*
* 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/
@andrewlimaza
andrewlimaza / add-compatibility-for-sed-and-pmpro-woo.php
Created May 19, 2023 04:56
Add compatibility for PMPro Set Expiration Date Add On and PMPro WooCommerce Add On.
<?php
/**
* Support Set Expiration Date Add On for PMPro WooCommerce Add On.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmprowoo_set_expiration_date( $level_array ) {
// Make sure Set Expiration Date Add On is active.
if ( ! function_exists( 'pmpro_getSetExpirationDate' ) ) {
return $level_array;
@andrewlimaza
andrewlimaza / default-bua-avatar.php
Created May 2, 2023 13:39
Default Basic User Avatar image when none is found
<?php
/**
* This assumes that Gravatar (or one of it's services is set as the default WP avatar option).
* Adjust this code and insert your own URL to the default avatar.
* Add this code to your site by following a guide like - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_bua_default_avatar_image( $avatar, $id_or_email ) {
if ( strpos( $avatar, 'secure.gravatar.com' ) !== false ) {
<?php //do not copy
/**
* This recipe will either add a fee or discount to specific variations of a Woo
* product based on the level that the user holds.
*
* In the below example, variation ID 107 should have level 1 and a fee of 1500 will be added.
* Variation ID 108 requires a level 2 and applies a discount of 8
*
* You can add this recipe to your site by creating a custom plugin
@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.
<?php //do not copy
/**
* This recipe associates a membership level with a Variable product's variation.
* You can specify that Variation A should get Level 1 and Variation B should get Level 2.
*
* Add variations/levels to the array in Line 31
*
* Use of this code recipe requires that the PMPro WooCommerce Add On is active.
*
<?php //do not copy
/**
* This code snippet checks if there's more than one item in the cart,
* finds the cheapest product and discounts it from the cart's total.
*/
function buyone_getone_free_discount() {
$contents = edd_get_cart_contents();