Skip to content

Instantly share code, notes, and snippets.

View andrewlimaza's full-sized avatar

Andrew Lima andrewlimaza

View GitHub Profile
@andrewlimaza
andrewlimaza / pmpro-allow-countries.php
Last active September 13, 2017 12:05 — forked from strangerstudios/pmpro-restrict-countries.php
Allow certain countries from signing up for certain levels.
<?php
// Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
function my_init()
{
global $allowed_countries;
//specify the countries allowed to signup. The key is the level id.
$allowed_countries = array(
@andrewlimaza
andrewlimaza / pmpro_order_codes.php
Created October 3, 2017 08:59 — forked from strangerstudios/pmpro_order_codes.php
Change how codes are generated for orders in Paid Memberships Pro. Add this code to your active theme's functions.php or a custom plugin.
/*
Set random order "code" to equal the order ID
It is important to keep the prefix (PMPRO-) below or change it to something else with a non-number in it.
If a code is all numeric, PMPro will go into an infinite loop when a new order is created.
*/
function my_pmpro_random_code($code, $order)
{
global $wpdb;
<?php
/*
Change term "membership" to "subscription" for plugin generated text
*/
function my_pmpro_gettext_membership($translated_text, $text, $domain)
{
if($domain == "paid-memberships-pro")
{
$translated_text = str_replace("Membership", "Subscription", $translated_text);
$translated_text = str_replace("membership", "subscription", $translated_text);
@andrewlimaza
andrewlimaza / custom
Last active February 13, 2018 06:35 — forked from Waller74/custom
<?php
/*
Plugin Name: PMPro Customizations
Plugin URI: https://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Customizations for my Paid Memberships Pro Setup
Version: .1
Author: Paid Memberships Pro
Author URI: https://www.paidmembershipspro.com
*/
@andrewlimaza
andrewlimaza / pmpro_after_change_membership_level_default_level.php
Last active February 16, 2018 12:31 — forked from strangerstudios/pmpro_after_change_membership_level_default_level.php
Place a PMPro member in another level when they cancel... unless they are cancelling from that level.
/*
When users cancel (are changed to membership level 0) we give them another "cancelled" level.
Can be used to downgrade someone to a free level when they cancel.
Will allow members to the "cancel level" to cancel from that though.
*/
function my_pmpro_after_change_membership_level_default_level($level_id, $user_id)
{
//Level ID of membership that you will allow level cancellation on. (Assume this is a free level or lower level than level ID 2 - see line 26)
$cancel_level_id = 1;
@andrewlimaza
andrewlimaza / Sublime-stuffs.txt
Last active April 20, 2023 23:56 — forked from pbrocks/Sublime-stuffs.txt
Install PHPCS with WordPress Coding Standard with Sublime Text 3
1. cmd+shift+p
2. Type phpcs and install it
3. Preferences > Package Settings > PHP Code Sniffer > Settings - User
@andrewlimaza
andrewlimaza / my_gettext_membership.php
Last active December 16, 2020 15:13 — forked from strangerstudios/my_gettext_membership.php
Change "Membership" to a different word with Paid Memberships Pro
// Change 'Membership' to 'Subscription' for Paid Memberships Pro.
function my_gettext_membership( $translated_text, $text, $domain ) {
if( "paid-memberships-pro" == $domain ) {
$translated_text = str_replace( "Membership Level", "Subscription", $translated_text );
$translated_text = str_replace( "membership level", "subscription", $translated_text );
$translated_text = str_replace( "membership", "subscription", $translated_text );
$translated_text = str_replace( "Membership", "Subscription", $translated_text );
}
return $translated_text;
}
@andrewlimaza
andrewlimaza / pmpro-auto-password-generation.php
Created May 10, 2018 12:55 — forked from strangerstudios/pmpro-auto-password-generation.php
Auto generate passwords with Paid Memberships Pro
/*
Automatically generate password on checkout page.
Note: if you want to remove the entire user area and generate usernames and passwords, simply set the pmpro_skip_account_fields filter to return false.
Use the intstructions here (http://www.paidmembershipspro.com/documentation/advanced-techniques/templates/) to add a checkout page template with the password fields removed.
Uncheck the "Default WP notification email. (Recommended: Leave unchecked. Members will still get an email confirmation from PMPro after checkout.)" option in the PMPro Emails Settings tab.
*/
function my_generate_passwords()
@andrewlimaza
andrewlimaza / pmpro-select-membership-duration.php
Last active February 19, 2019 17:09 — forked from travislima/pmpro-select-membership-duration.php
Allows customers to select membership duration at checkout. Adjusts the amount charged and expiration date of the membership accordingly.
<?php
/*
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Allows customers to select membership duration at checkout. Adjusts the amount charged and expiration date of the membership accordingly.
* Requires the Paid Memberships Pro Register Helper Add On to be installed and activated in order to work - https://www.paidmembershipspro.com/add-ons/pmpro-register-helper-add-checkout-and-profile-fields/
*/
function my_pmprorh_init() {
@andrewlimaza
andrewlimaza / hide_old_posts_from_members.php
Last active June 13, 2018 07:12 — forked from strangerstudios/hide_old_posts_from_members.php
Paid Memberships Pro: Hide Old Posts From New Members
/*
This code will create a content filter for all pages and posts to remove access to posts that were published before a member's join date. Only posts or pages which require membership will be hidden. Note that pages and posts that require membership will still be hidden from non-members regardless of the publish date.
The params passed are:
$hasaccess - (bool) what PMPro thinks about whether the user has access
$thepost - (post object) the post being checked, usually the current post
$theuser - (user object) the user being checked, usually the current user
$post_membership_levels - (array of levels) the levels this post requires (if any)
*/
add_filter("pmpro_has_membership_access_filter", "hide_old_posts_from_members", 10, 4);