Skip to content

Instantly share code, notes, and snippets.

View lubyagin's full-sized avatar

Александр lubyagin

View GitHub Profile
@andrewlimaza
andrewlimaza / custom-depends-register-helper-simple-example.php
Created August 29, 2018 14:04
Multiple Depends example for Register Helper and Custom JQuery.
<?php
/**
* This is a simple example that references a select drop down and when a certain option is selected will it show.
* Add this code to your PMPro Customizations and tweak to your liking.
*/
function my_pmprorh_init() {
//don't break if Register Helper is not loaded
if(!function_exists( 'pmprorh_add_registration_field' )) {
return false;
@andrewlimaza
andrewlimaza / pmpro-register-helper-fields.php
Last active February 19, 2019 15:10 — forked from BusyBLibrary/pmpro-register-helper-fields.php
Modified PMPro Register Helper Example with fields for school, county, job title, race, ethnicity, languages spoken, and gender.
<?php
/*
Plugin Name: Register Helper Example
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Register Helper Initialization Example
Version: .2
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
@andrewlimaza
andrewlimaza / change-recurring-payment-reminder.php
Created August 17, 2018 09:22
Change when recurring payment reminders are sent for Paid Memberships Pro.
<?php
/**
* Send recurring subscription payment email reminder 14 days before subscription payment.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_change_recurring_emails( $emails ) {
// Remove the email that is sent 7 days before subscription payment.
unset( $emails[7] );
@andrewlimaza
andrewlimaza / my_pmpro_after_change_membership_level.php
Last active February 21, 2022 14:14 — forked from strangerstudios/my_pmpro_after_change_membership_level.php
Only allow users to use the trial levels once with Paid Memberships Pro.
<?php
/**
* Only allow users to use the trial level once. This does not affect pre-existing members that had a level before this code is implemented.
* Be sure to change the $trial_levels variable in multiple places.
* You may add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
//record when users gain the trial level
function my_pmpro_after_change_membership_level($level_id, $user_id)
{
//set this to the id of your trial level
@andrewlimaza
andrewlimaza / replace_spaces_with_underscores.php
Last active February 19, 2019 15:11
Replace spaces with underscore "_" for usernames.
<?php
/**
* Replace all spaces with an underscore when new users register for Paid Memberships Pro.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_custom_user_registration_changes( $userdata ) {
$userdata['user_login'] = str_replace(' ', '_', $userdata['user_login'] );
@andrewlimaza
andrewlimaza / redirect-member-away-from-page.php
Created August 6, 2018 08:13
redirect user away from the page if they do not have a specific membership level.
<?php
/**
* This will redirect members with level 1 from site.com/page-slug to the home page.
* Please adjust accordingly and add to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function redirect_member_from_page_x() {
if ( is_page( 'page-slug' ) && pmpro_hasMembershipLevel( 1 ) ) {
wp_redirect( home_url() ); //redirect to home page. Change home_url() to home_url( '/page-slug' ) to redirect to specific page.
@andrewlimaza
andrewlimaza / my-shortcode-example-startdate.php
Created July 31, 2018 10:20
Get user's startdate for Paid Memberships Pro
<?php
/**
* Creates a shortcode [member_startdate] and returns a readable date if the user has a membership startdate.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_shortcode_example() {
global $wpdb, $current_user;
@andrewlimaza
andrewlimaza / generate_member_number.php
Created July 25, 2018 08:55 — forked from strangerstudios/generate_member_number.php
Generate a "Member Number" for WordPress users and show it on the PMPro account page.
<?php
/*
Member Numbers
* Change the generate_member_number function if your member number needs to be in a certain format.
* Member numbers are generated when users are registered or when the membership account page is accessed for the first time.
*/
//Generate member_number when a user is registered.
function generate_member_number($user_id)
{
@andrewlimaza
andrewlimaza / pmpro-change-not-paying.php
Created July 23, 2018 08:28
Change 'Not Paying.' to 'Paying.' for Paid Memberships Pro.
<?php
/**
* Changes 'Not Paying.' to 'Paying.' inside Paid Memberships Pro.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function change_not_paying_to_paying_pmpro( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
@andrewlimaza
andrewlimaza / restrict-all-pages-non-members.php
Last active November 18, 2022 00:24
Restrict all pages except home and Paid Memberships Pro pages for non-members.
<?php
/**
* This will restrict all pages except Paid Memberships Pro pages or the home page of your website to non-members / non-approved members / logged-out users.
* This won't affect administrators.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_redirect_non_members() {
global $pmpro_pages;