Skip to content

Instantly share code, notes, and snippets.

View andrewlimaza's full-sized avatar

Andrew Lima andrewlimaza

View GitHub Profile
@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 ) {
@andrewlimaza
andrewlimaza / user-fields-2-cols-example.php
Last active August 27, 2024 12:26
Make default "More Information" User Fields 2 columns Paid Memberships Pro
<?php
/**
* Make the "More Information" container for custom fields 2 columns at Paid Memberships Pro checkout.
* Tweak the code below to work for your needs and any other field group you may have.
* Follow this guide to add custom code to your WordPress site - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_custom_add_jquery_script() {
?>
<script type="text/javascript">
@andrewlimaza
andrewlimaza / pmpro-zapier-add-is-renewal-added-order.php
Created August 22, 2024 08:12
Add "is renewal" to PMPro Zapier (plugin) New Order outbound events.
<?php
/**
* Add 'is_renewal' to the data load sent to Zapier when using the New Order trigger for PMPro Zapier Add On.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_add_custom_field_added_order( $data, $order, $user_id ) {
if ( $order->is_renewal() ) {
$data['is_renewal'] = true;
} else {
$data['is_renewal'] = false;
@andrewlimaza
andrewlimaza / avoid-double-loading-select2-gamipress-leaderboard.php
Created August 20, 2024 07:20
Remove "select2" from Gamipress Leaderboard pages to avoid double loading.
<?php
/**
* Remove Paid Memberships Pro select2 from the GamiPress Leaderboard settings pages.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_custom_dequeue_select2() {
if ( isset( $_REQUEST['post_type'] ) && 'gp_leaderboard' == $_REQUEST['post_type'] ) {
wp_dequeue_script( 'select2' );
wp_deregister_script( 'select2' );
}
@andrewlimaza
andrewlimaza / wll-user-stats-custom-role-admin.php
Created August 19, 2024 17:37
When Last Login - User Statistics (Custom Role Filter)
<?php
/**
* Tweak the user capability required to view the When Last Login - User Statistics charts/reporting.
* This requires V1.1+ of When Last Login - User Statistics.
* Add this code to your site by following this guide - https://yoohooplugins.com/customize-wordpress/
*/
function my_wll_user_stats_admin_cap( $capability ) {
return 'edit_users'; // Change this to the custom capability value.
}
add_filter( 'wll_stats_access_cap', 'my_wll_user_stats_admin_cap', 10, 1 );
@andrewlimaza
andrewlimaza / pmpro-admin-disable-select-2.php
Last active August 19, 2024 10:50
Dequeue select2 in WordPress admin for non Paid Memberships Pro pages that may also be loading select2.
<?php
/**
* Remove select2.js and select2.css on non-pmpro pages to prevent conflicts within the WordPress admin.
* Only use this if you are 100% certain that the conflict is due to select2 being loaded more than once.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_custom_dequeue_select2() {
// Bail if we're on PMPro pages, but remove select2 from all other admin pages.
if ( ! empty( $_REQUEST['page'] ) && strpos( $_REQUEST['page'], 'pmpro' ) !== false ) {