Skip to content

Instantly share code, notes, and snippets.

View andrewlimaza's full-sized avatar

Andrew Lima andrewlimaza

View GitHub Profile
@carlosleopoldo
carlosleopoldo / select-users.sql
Last active September 12, 2019 23:09
Select users in WordPress without specific user meta key and user id upper than...
-- Select users in WordPress without specific user meta key
-- * Replace meta_name for your meta key
-- * Replace > 0 for the minimum user ID
SELECT wp_users.ID
FROM wp_users
WHERE wp_users.ID > 0
AND wp_users.ID NOT IN (
SELECT DISTINCT user_id FROM wp_usermeta WHERE meta_key = 'meta_name'
)
@strangerstudios
strangerstudios / pmpro_clear_all_data_init.php
Last active July 22, 2023 09:43
Clear out all PMPro member and report data. (Back up your database first. For development use only. Use at your own risk!!!)
/*
Clear out all PMPro member and report data. (Back up your database first. Use at your own risk!!!)
This will delete all orders, members/level data, and reporting data.
Your levels, discount codes, and settings will remain in place.
All users will remain users (without memberships).
All subscriptions at the gateway will remain active.
To Use:
* Copy this code into your active theme's functions.php or a custom WP plugin.
* Navigate to /wp-admin/?pmprocleardata=1 when logged in as an admin.
@strangerstudios
strangerstudios / pmpro_register_redirect.php
Created November 14, 2014 21:44
Disable the PMPro redirect from default WordPress register page to PMPro levels page.
//add this line to your active theme's functions.php or a custom plugin
add_filter('pmpro_register_redirect', '__return_false');
@Spreeuw
Spreeuw / dokan-invoice-filters.php
Last active June 23, 2020 06:28
Dokan PDF Invoices
<?php
/*******************************
** DOKAN PDF INVOICE FILTERS **
*******************************/
/**
* Replace the main shop name with "Store Info" (actual shop name listed below)
*/
add_filter( 'wpo_wcpdf_shop_name', 'wpo_wcpdf_add_dokan_shop_name', 10, 1 );
function wpo_wcpdf_add_dokan_shop_name ( $shop_name ) {
@strangerstudios
strangerstudios / pmpromyCRED.php
Last active July 9, 2021 22:56
Award MyCRED points for members who sign up for Membership Level 1.
<?php
/*
Use this recipe in combination with MyCRED to award points to members when signing up
for Level 1 membership. This code gist could be customized to give points for another
membership level ID, award recurring points for each subscription payment, and more.
MyCRED can be downloaded/configured here: https://wordpress.org/plugins/mycred/
*/
// Register Hook for PMPro Membership Points at Signup
@barbietunnie
barbietunnie / stop-mac-apache.sh
Created February 25, 2017 22:42
Stop Default Apache server running on Mac OS Sierra
sudo apachectl stop
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
@ideadude
ideadude / my_pmpro_orders_read_only_fields.php
Created December 26, 2017 17:34
make all fields (including transaction ids) editable on the orders page in the PMPro dashboard
/*
Make all fields (including transaction ids) editable on the orders page in the PMPro dashboard.
Add this code to a custom plugin.
*/
function my_pmpro_orders_read_only_fields($fields)
{
return array();
}
add_filter('pmpro_orders_read_only_fields', 'my_pmpro_orders_read_only_fields');
@ideadude
ideadude / init_create_my_administrator_user.php
Created February 13, 2018 17:23
Create a WordPress administrator user account via PHP/FTP.
<?php
/*
Sometimes you have FTP access to a site, but don't have a WP administrator account.
You can use this code to create one.
1. Add this code into any plugin or theme file that you know will be run.
2. Visit /?createmyadministratoruser=1.
3. Delete the code you added.
*/
function init_create_my_administrator_user() {
@messica
messica / my_pmpro_applydiscountcode_return_js.php
Last active March 25, 2022 16:00
Display original price and discount when a discount code is applied.
<?php
/**
* Display messages of the Original Price, Discounted Price and Amount Saved when discount code is applied to PMPro order.
* Add this code recipe to a PMPro Customization Plugin - Display messages of the Original Price, Discounted Price and Amount Saved when discount code is applied to PMPro order
* Various classes added to strings to allow for styling - ".pmpro-discorig-message", ".pmpro-orginal-price", ".pmpro-discount-price", ".pmpro-save-price"
*
* [my_pmpro_applydiscountcode_return_js] Display original price and discount when a discount code is applied.
* @param string $discount_code [description]
* @param integer $discount_code_id [description]
@ideadude
ideadude / my_pmpro_forward_ipn.php
Created May 4, 2019 15:53
Forward PMPro PayPal IPNs to another domain
/**
* Forward PMPro PayPal IPNs to another domain.
* Each domain will process the IPNs. The IPN handlers should be setup to ignore
* messages that aren't for that site. PMPro does this.
* This is useful if you have 2 different sites using the same PayPal account
* and the IPN is setup to go to a PMPro site.
* Add this to a custom plugin on the PMPro site the IPN hits.
* Update the domain/url to the IPN you want to forward to.
* The pmprodev_gateway_debug_setup check makes sure this DOESN'T run if you have the
* PMPro Toolkit plugin enabled, i.e. you are on a staging site.