Skip to content

Instantly share code, notes, and snippets.

View andrewlimaza's full-sized avatar

Andrew Lima andrewlimaza

View GitHub Profile
<?php
/**
* Add the code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
//we have to put everything in a function called on init, so we are sure Register Helper is loaded
function my_pmprorh_init()
{
//don't break if Register Helper is not loaded
if(!function_exists( 'pmprorh_add_registration_field' )) {
return false;
@andrewlimaza
andrewlimaza / pmpro-australia-gst.php
Last active July 23, 2018 10:21 — forked from strangerstudios/pmpro-australia-gst.php
Paid Memberships Pro - Australia GST
<?php
/*
Plugin Name: Paid Memberships Pro - Australia GST
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-australia-gst/
Description: Apply Australia GST to Checkouts with PMPro
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
/*
@andrewlimaza
andrewlimaza / my_pmprowoo_get_membership_price.php
Created July 4, 2018 16:52 — forked from ideadude/my_pmprowoo_get_membership_price.php
Use the pmprowoo_get_membership_price filter to set prices for variable products with Paid Memberships Pro and WooCommerce
<?php
/**
* Use the pmprowoo_get_membership_price filter to set prices for variable products.
* Update the $membership_prices array.
* Each item in that array should have a key equal to the membership level id,
* and a value equal to an array of the form array( {variable_product_id} => {member_price} )
*
* Add this code into a custom plugin.
*/
function my_pmprowoo_get_membership_price( $discount_price, $level_id, $original_price, $product ) {
@andrewlimaza
andrewlimaza / generate_member_number.php
Created July 25, 2018 08:55 — forked from strangerstudios/generate_member_number.php
Generate a "Member Number" for WordPress users and show it on the PMPro account page.
<?php
/*
Member Numbers
* Change the generate_member_number function if your member number needs to be in a certain format.
* Member numbers are generated when users are registered or when the membership account page is accessed for the first time.
*/
//Generate member_number when a user is registered.
function generate_member_number($user_id)
{
@andrewlimaza
andrewlimaza / my_pmpro_after_change_membership_level.php
Last active February 21, 2022 14:14 — forked from strangerstudios/my_pmpro_after_change_membership_level.php
Only allow users to use the trial levels once with Paid Memberships Pro.
<?php
/**
* Only allow users to use the trial level once. This does not affect pre-existing members that had a level before this code is implemented.
* Be sure to change the $trial_levels variable in multiple places.
* You may add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
//record when users gain the trial level
function my_pmpro_after_change_membership_level($level_id, $user_id)
{
//set this to the id of your trial level
@andrewlimaza
andrewlimaza / pmpro_start_session.php
Created August 14, 2018 13:52 — forked from ideadude/pmpro_start_session.php
Tell PMPro to start the PHP session earlier.
/**
* Add this code into a custom plugin.
* You could also add a direct call to session_start() in your wp-config.php
* or another piece of code that runs early.
*/
add_action('plugins_loaded', 'pmpro_start_session');
@andrewlimaza
andrewlimaza / index.js
Created August 15, 2018 12:26 — forked from MoOx/index.js
Export/import github labels
// go on you labels pages
// eg https://github.com/cssnext/cssnext/labels
// paste this script in your console
// copy the output and now you can import it using https://github.com/popomore/github-labels !
var labels = [];
[].slice.call(document.querySelectorAll(".label-link"))
.forEach(function(element) {
labels.push({
name: element.textContent.trim(),
@andrewlimaza
andrewlimaza / pmpro-register-helper-fields.php
Last active February 19, 2019 15:10 — forked from BusyBLibrary/pmpro-register-helper-fields.php
Modified PMPro Register Helper Example with fields for school, county, job title, race, ethnicity, languages spoken, and gender.
<?php
/*
Plugin Name: Register Helper Example
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Register Helper Initialization Example
Version: .2
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
@andrewlimaza
andrewlimaza / my_pmpro_pre_handle_404.php
Created September 4, 2018 14:34 — forked from strangerstudios/my_pmpro_pre_handle_404.php
If we 404, and the slug matches a pmpro discount code, redirect
/*
If we 404, and the slug matches a discount code, redirect
Add this code to a custom plugin
*/
function my_pmpro_pre_handle_404($preempt, $wp_query) {
global $wpdb;
//bail if PMPro is not installed
if(empty($wpdb->pmpro_discount_codes_levels))
@andrewlimaza
andrewlimaza / pmpro-add-pdf-invoice-attachment.php
Last active October 22, 2021 08:08 — forked from greathmaster/pmpro-add-pdf-invoice-attachment.php
Adds a PDF invoice attachment to checkout emails.
<?php
/*
Add a PDF attachement of the invoice to the checkout email. This code gist must be configured...
1) Download the DOMPDF library: https://github.com/dompdf/dompdf
1.1) Save to wp-content/your-plugin/
2) Download the PHP SVG library: https://github.com/PhenX/php-svg-lib
2.1) Save to dompdf/lib/
3) Download the PHP FONT library: https://github.com/PhenX/php-font-lib
3.1) Save to dompdf/lib/