Skip to content

Instantly share code, notes, and snippets.

View andrewlimaza's full-sized avatar

Andrew Lima andrewlimaza

View GitHub Profile
@andrewlimaza
andrewlimaza / ccbill-sub-account-pmpro-checkout.php
Created November 22, 2024 08:09
Adjust CCBill Sub Account for Paid Memberships Pro Checkouts
<?php
/**
* Change the CCBill Sub Account for AddOn Package purchase.
* This can be tweaked further to change the subaccount (or any other argument) based on custom conditionals.
*
* REQUIRES PMPRO CCBILL 0.6+
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_ccbill_change_sub_account( $ccbill_args, $order ) {
// Let's replace the subaccount when we get AddOn Package purchase.
@andrewlimaza
andrewlimaza / remove-email-validation-on-certain-pages.php
Created November 6, 2024 06:52
Remove Email Validation checks on Edit Member and Frontend Edit Profile page to allow updating of User Fields.
<?php
/**
* Removes the email validation checks on the Edit Member and Frontend Edit Profile pages.
* This allows pending validation members to edit their own User Fields.
* This is only needed if the "Restrict Fields For Membership Levels" 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_pmpro_email_bypass_validation_frontend() {
global $pmpro_pages;
@andrewlimaza
andrewlimaza / pmpro-min-age-checkout.php
Created November 5, 2024 08:02
Require accounts to be 18 years or older, in order to checkout and signup for a membership level.
<?php
/**
* Require age verification before being able to signup for a membership level.
* Create a Date field in User Fields and rename the $dob_field_name and adjust the $min_age values.
* This supports PMPro V3.2+ and has backwards compatibility, please read the comments.
*
* To add this customization to your site, please follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_min_required_age( $okay ) {
@andrewlimaza
andrewlimaza / user-fields-required-pmpro.php
Created November 4, 2024 07:02
Make User Fields required on the Edit User Profile Page for Paid Memberships Pro
<?php
/**
* This gist makes all the User Fields listed below in each if statement required.
* Only save the user's profile when all fields are submitted and not 0 values.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_make_profile_fields_required( &$errors, $update = null, &$user = null ) {
// Validate the custom User Fields.
if ( empty( $_REQUEST['last_name'] ) ) {
@andrewlimaza
andrewlimaza / pmpro-group-accounts-wp-menu-dynamic-link.php
Last active January 27, 2025 09:57
Create dynamic "Manage Account" link to be used in WordPress Menus for Paid Memberships Pro Group Accounts
@andrewlimaza
andrewlimaza / replace-pmpro-social-login-checkout-text.php
Created September 20, 2024 07:18
Replace PMPro Social Login checkout text.
<?php
/**
* Replace the checkout text for PMPro's Social Login Add On.
* Follow this guide to add custom code to your site - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_social_login_text_replace( $translated_text, $text, $domain ) {
// Check if the domain and text match the target string
if ( $domain === 'pmpro-social-login' ) {
if ( $text === 'Click here to login, create a username and password' ) {
@andrewlimaza
andrewlimaza / pmpro-hide-checkout-button-logged-out.php
Last active September 19, 2024 07:55
Hide checkout button for PMPro when user is logged-out.
<?php
/**
* Hide the PMPro Checkout button when user isn't logged-in.
* To add this code to your site, please follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_hide_checkout_button() {
// Bail if PMPro isn't active or not the checkout page.
if ( ! function_exists('pmpro_is_checkout' ) || ! pmpro_is_checkout() ) {
return;
}
@andrewlimaza
andrewlimaza / pmpro-checkout-level-css.php
Created September 17, 2024 06:31
Load custom CSS per membership checkout for Paid Memberships Pro
<?php
/**
* Load custom CSS only for levels 2 or 8 at checkout. Tweak the array value for your level ID's
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_load_css_per_level() {
if ( ! function_exists( 'pmpro_getLevelAtCheckout' ) ) {
return;
}
@andrewlimaza
andrewlimaza / pmpro-add-email-template-variables.php
Created September 9, 2024 11:45
PMPro add !!title!! and !!surname!! to all email templates.
<?php
/**
* Creates and adds !!title!! and !!surname!! email variables to use in email templates.
* Supports Paid Memberships Pro V3.0+
* To add this code to your site, please follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_add_custom_variables( $data, $email ) {
global $current_user;
// Is the emails for admins? If so, let's get the user ID from elsewhere (currently logged in or whoever the email is being sent to)
@andrewlimaza
andrewlimaza / pmpro-change-choose-a-membership-level-wording-example.php
Created September 6, 2024 07:53
Change PMPro Account page "Choose a membership level" wording.
<?php
/**
* Change the "Choose a membership level" wording on the Paid Memberships Pro account page.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_account_page_gettext_changes( $translated, $text, $domain ) {
switch ( $domain ) {
case 'paid-memberships-pro':
switch ( $text ) {