Skip to content

Instantly share code, notes, and snippets.

View ipokkel's full-sized avatar

Theuns Coetzee ipokkel

View GitHub Profile
@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 / 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();
<?php //do not copy
/**
* Gets the next payment date and marks that as the expiration date for users.
*
* The "next payment" value is an estimate based on the billing cycle of the subscription and the last order date. It may be off from the actual recurring date set at the gateway, especially if the subscription was updated at the gateway.
*
* Remove the // on line 40 to run the update query.
*
* You can add this recipe to your site by creating a custom plugin
@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;
@ipokkel
ipokkel / add-billing-fields-to-user-profile-edit.php
Last active August 19, 2022 06:25
Add PMPro Billing Address fields to the user profile edit pages.
<?php
/**
* This will add billing fields to the administrative user profile edit page for administrators
* and on the frontend PMPro user Edit Profile page for members.
*
* 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/
*/