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-add-fields-checkout-send-data-zapier.php
Last active October 24, 2024 06:41
Paid Memberships Pro - Add Fields to Checkout and Pass Data to Zapier
<?php
function my_pmprorh_init() {
// Don't break if Register Helper is not loaded.
if ( ! function_exists( 'pmprorh_add_registration_field' ) ) {
return false;
}
// Define the fields.
$fields = array();
$fields[] = new PMProRH_Field(
@ronalfy
ronalfy / pmpro-show-content-list.php
Created April 30, 2020 16:22
Paid Memberships Pro - Show Content List
<?php
/**
* Show pages/posts a level/user has access to.
*
* @param array $atts Shortcode attributes.
*
* @return string HTML for the post list.
*/
function member_content_list( $atts ) {
if ( ! is_user_logged_in() ) {
@ronalfy
ronalfy / pmpro-ban-email-domains.php
Created May 28, 2020 12:42
Paid Memberships Pro - Ban Email Domains
<?php
function pmpro_custom_banned_domains( $continue_registration ) {
global $pmpro_msg, $pmpro_msgt;
if ( isset ( $_REQUEST['bemail'] ) ) {
$bemail = sanitize_email( stripslashes( $_REQUEST['bemail'] ) );
$banned_email_domains = array(
'.ru', /* Add more email domains here */
);
foreach ( $banned_email_domains as $domain ) {
if ( strstr( $bemail, $domain ) ) {
@ronalfy
ronalfy / pmpro-ms-redirect.php
Created June 2, 2020 16:26
Paid Memberships Pro - Multisite Redirect
<?php
function pmpro_multisite_subsite_custom_redirect() {
if ( is_main_site() || is_admin() ) {
return;
}
if ( function_exists( 'pmpro_hasMembershipLevel' ) ) {
global $current_user;
if ( 0 == $current_user->ID || ! pmpro_hasMembershipLevel() ) {
wp_redirect( get_site_url( 1, '/membership-account/membership-levels/' ) ); // Assume main site ID is 1.
exit;
@ronalfy
ronalfy / pmpro-bulgarian-currency.php
Created June 29, 2020 17:36
Paid Memberships Pro - Bulgarian Currency
<?php
// Adds the BGN currency to currency list.
function pmpro_currencies_bulgarian( $currencies ) {
$currencies['BGN'] = __( 'Bulgarian', 'pmpro' );
return $currencies;
}
add_filter( 'pmpro_currencies', 'pmpro_currencies_bulgarian' );
@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;
} );
@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-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 / 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-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' );