Skip to content

Instantly share code, notes, and snippets.

View ronalfy's full-sized avatar
🏠
Working from home

Ronald Huereca ronalfy

🏠
Working from home
View GitHub Profile
@ronalfy
ronalfy / pmpro-make-reason-cancelled-optional.php
Created August 27, 2020 18:34
Paid Memberships Pro - Make Reason Cancelled Optional
<?php
/**
* Makes reason for cancelling text field optional.
*/
function pmpro_custom_remove_required_cancel() {
remove_action( 'init', 'pmpror4c_init' );
}
add_action( 'init', 'pmpro_custom_remove_required_cancel', 9 );
@ronalfy
ronalfy / pmpro-add-company-required-country.php
Last active September 21, 2020 13:42
PMPro - Add Company - Remove Required Fields - Change Default Country
<?php
/**
* Adds a Register Helper item.
* Only allows certain billing fields to be required.
* Sets default country selected to Japan
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
@ronalfy
ronalfy / pmpro-template-user-pages-level-id.php
Last active August 28, 2020 13:30
PMPro - Template for User Pages Based on Level ID.
<?php
/**
* Load a page template for a user page based on level.
*/
function pmpro_user_page_redirect_per_level() {
// Make sure user is logged in.
if ( ! is_user_logged_in() ) {
return;
}
// Make sure we are on a page.
@ronalfy
ronalfy / pmpro-restrict-email-level.php
Created August 12, 2020 15:11
Paid Memberships Pro - Restrict Email for Level
<?php
/**
* Restrict Membership Signup by Email Domain
* Make sure to edit the $valid_domains array defined further below
* to include only the domains you'd like to allow.
*
* Add this code to a custom plugin. More info: https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_registration_checks_restrict_email_addresses( $value ) {
global $pmpro_level;
@ronalfy
ronalfy / enable-auto-updates-plugins-themes-flywheel.php
Created August 12, 2020 00:27
Enable Automatic Updates Plugins/Themes on Flywheel
<?php
/* Enable auto-updates of plugins/themes with cron */
add_action(
'wp_update_plugins',
function() {
if ( wp_doing_cron() && ! doing_action( 'wp_maybe_auto_update' ) ) {
do_action( 'wp_maybe_auto_update' );
}
},
20
@ronalfy
ronalfy / pmpro-use-recaptcha-net.php
Created August 6, 2020 22:29
Paid Memberships Pro - Use Recaptcha.net
<?php
/* Change from using google.com Recaptcha to recaptcha.net */
add_action( 'init', function() {
remove_action( 'wp', 'pmpro_init_recaptcha', 5 );
remove_action( 'init', 'pmpro_init_recaptcha', 20);
}, 5 );
function pmpro_init_recaptcha_action_override() {
//don't load if setting is off
global $recaptcha, $recaptcha_validated;
$recaptcha = pmpro_getOption( 'recaptcha' );
@ronalfy
ronalfy / pmoro-move-state-field-above-phone-number.php
Last active July 31, 2020 14:07
Paid Memberships Pro - Move State field Above Phone Number in Checkout
<?php
/**
* This recipe moves the state field above the phone number during checkout.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmpro_custom_state_field_above_phone_number() {
@ronalfy
ronalfy / pmpro-level-page-landing-page-redirect.php
Created July 27, 2020 18:24
Paid Memberships Pro - Level Page Landing Page Redirect
<?php
/**
* Redirect non-premium members to landing page.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_temporary_restrict_access() {
// Ignore redirecting for non-logged in users. PMPro should take care of non-logged-in access.
if ( ! is_user_logged_in() ) {
return;
}
@ronalfy
ronalfy / pmpro-skip-admin-tracking.php
Last active March 27, 2021 00:03
Paid Memberships Pro - Skip Tracking for Admins
<?php
/**
* Remove stats tracking for admins.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmpro_remove_admin_tracking_skip() {
if ( current_user_can( 'administrator' ) ) {
remove_action( 'wp_head', 'pmpro_report_login_wp_views' );
}
}
@ronalfy
ronalfy / pmpro-body-class-level-coupon.php
Created July 21, 2020 16:56
Body Class based on Membership Level and Coupon
<?php
/* Code will add CSS class charity-page to the <body> tag when level and discount code are present in the URL */
add_filter( 'body_class', function( $classes ) {
if ( isset( $_REQUEST['level'] ) && isset( $_REQUEST['discount_code'] ) ) {
// Additional checks can be done here to ensure the correct level and discount code value.
$classes[] = 'charity-page';
}
return $classes;
} );