Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Lima andrewlimaza

View GitHub Profile
@andrewlimaza
andrewlimaza / pmpro-show-member-id-bp-profile.php
Created May 19, 2022
Show Member ID on BuddyPress profile
View pmpro-show-member-id-bp-profile.php
<?php
/**
* Show a Member ID on the BuddyPress profile page.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmpro_bp_show_member_id_bp_profile() {
global $current_user;
if ( !function_exists('pmpro_getMembershipLevelForUser') ) {
return;
@andrewlimaza
andrewlimaza / pmpro-woo-custom-dev.php
Last active May 4, 2022
Custom WooCommerce Discount. Ignore level in cart discount
View pmpro-woo-custom-dev.php
<?php
/**
* Adjust WooCommerce membership discount, ignores products in cart discount.
* Only allow membership discounts for active levels.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_woo_custom_discount( $membership_price, $level_id, $price, $product ) {
global $pmprowoo_member_discounts, $current_user;
@andrewlimaza
andrewlimaza / pmproz-updated-order-trigger.php
Created Apr 21, 2022
Add custom fields to PMPro Zapier Plugin Updated Order Trigger
View pmproz-updated-order-trigger.php
<?php
/**
* Add custom fields to PMPro's Zapier Plugin "Updated Order" trigger.
* To add this code snippet to your site, please follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmproz_add_fields_to_trigger_example( $data, $order, $user_id ) {
$data['company_name'] = get_user_meta( $user_id, 'company_name', true );
$data['university_name'] = get_user_meta( $user_id, 'university_name', true );
@andrewlimaza
andrewlimaza / pmpro-zapier-after-checkout-trigger-shipping-fields.php
Created Mar 16, 2022
Add Shipping Address Fields To PMPro Zapier - After Checkout Trigger
View pmpro-zapier-after-checkout-trigger-shipping-fields.php
<?php
/**
* Add the Shipping Address field data to Zapier posted data when using the After Checkout trigger.
* Add the code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function add_custom_data_to_after_checkout( $data, $user_id, $level, $order ) {
$shipping_fields = array(
'sfirstname',
'slastname',
@andrewlimaza
andrewlimaza / conpd-immediately-if-trial.php
Created Mar 15, 2022
Cancel on Next Payment Date + Subscriptions Delay Add On. Cancel Members Immediately if on trial.
View conpd-immediately-if-trial.php
<?php
/**
* Tries to cancel members immediately if they are cancelling within the Subscription Delay Limit of their level.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
/**
* Is a user currently in a subscription delay based on their membership level.
*
@andrewlimaza
andrewlimaza / pmpro-paypal-website-payments-pro-pbc.php
Created Mar 2, 2022
Remove PBC Scripts temporarily if setting is "Only allow default gateway"
View pmpro-paypal-website-payments-pro-pbc.php
<?php
/**
* Remove Pay By Check Logic for PayPal Website Payments Pro when "Default Gateway Only" option is selected.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_unhook_settings_pbc() {
if ( ! empty( $_REQUEST['level'] ) ) {
$level_id = intval( $_REQUEST['level'] );
$options = pmpropbc_getOptions( $level_id );
@andrewlimaza
andrewlimaza / pay-by-check-payment-options.css
Created Mar 1, 2022
Add logo to Payment Select Options for Pay By Check Add On (Workaround) - CSS
View pay-by-check-payment-options.css
/**
* Make sure your images are uploaded to /images folder. This was tested using Divi and Pay By Check Add On.
* Adapted from this article - https://www.paidmembershipspro.com/add-credit-card-and-paypal-logos-to-checkout/
*
*/
/* CSS Document */
#pmpro_payment_method span.gateway_paypalexpress a{
background-position: bottom left;
background-repeat: no-repeat;
@andrewlimaza
andrewlimaza / owner-of-io-required-level.php
Created Feb 25, 2022
Owner of invite code needs to have a relevant membership level for code's to be used.
View owner-of-io-required-level.php
<?php
/**
* Owner of the Invite Code, has to hold any active $pmproio_invite_given_levels level in order for the code to be redeemed.
* Please ensure you set an Invite Only Level ID for recipients.
* You may tweak this to be more specific to your level or site needs.
*
* Add this to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function invite_only_members_registration_checks( $okay ) {
global $pmpro_level, $pmproio_invite_required_levels, $pmproio_invite_given_levels;
@andrewlimaza
andrewlimaza / pmpro-approvals-delete-deny.php
Created Feb 18, 2022
Delete User on PMPro Approvals Deny. Delete denied user.
View pmpro-approvals-delete-deny.php
<?php
/**
* Automatically delete user when their approval is denied.
* Add this code to your site by following: https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmpro_approvals_delete_member_on_deny( $user_id, $level_id ) {
wp_delete_user( $user_id );
}
add_action( 'pmpro_approvals_after_deny_member', 'pmpro_approvals_delete_member_on_deny', 10, 2 );
@andrewlimaza
andrewlimaza / add-discount-code-zapier-after-checkout.php
Created Feb 17, 2022
Add Discount Code Used for PMPro Zapier Plugin (After Checkout)
View add-discount-code-zapier-after-checkout.php
<?php
/**
* Add discount code value to "After Checkout" Webhook trigger for PMPro Zapier Plugin.
*
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*
*/
function pmpro_zapier_add_discount_code( $data ) {
$data['discount_code'] = sanitize_text_field( $_REQUEST['discount_code'] );
return $data;