Skip to content

Instantly share code, notes, and snippets.

View andrewlimaza's full-sized avatar

Andrew Lima andrewlimaza

View GitHub Profile
@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 / 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 / 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
*/
<?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 / 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;
@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 / my_pmpro_widget_display_callback.php
Last active September 4, 2017 08:20 — forked from strangerstudios/my_pmpro_widget_display_callback.php
Hide widgets by sidebar ID on members only content when the current user does not have access.
<?php
/*
Update line 8 with the array of sidebar IDs you want to filter.
Add this code to your active theme's functions.php or a custom plugin.
*/
function my_pmpro_widget_display_callback($instance, $widget, $args) {
$hide_sidebars_array = array('sidebar-1','sidebar-2');
global $post;
//check if current user has an active membership level and hide the sidebars.
@andrewlimaza
andrewlimaza / pmpro-assign-username-at-checkout.php
Created August 29, 2017 07:14 — forked from greathmaster/pmpro-assign-username-at-checkout.php
Assigns a random 6 digit number for a username automatically. Two variations...the first will show the username field with number already filled, but editing is disabled. The second variations (uncomment the lines) will not show the username field at all, but will simply generate the numerical username and display it on the confirmation page.
/*
Assigns a random 6 digit number for a username automatically.
Two variations...
the first will show the username field with number already filled, but editing is disabled.
The second variations (uncomment the lines) will not show the username field at all, but will simply generate the numerical username and display it on the confirmation page.
*/
function my_pmpro_checkout_after_user_fields()
{
echo "<script>";
@andrewlimaza
andrewlimaza / gist:49f30f9d91970eaf2fd0d7dc4f095a40
Created August 1, 2017 08:37 — forked from vxnick/gist:380904
Array of country codes (ISO 3166-1 alpha-2) and corresponding names
<?php
$countries = array
(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',
@andrewlimaza
andrewlimaza / pmpromyCRED.php
Last active May 15, 2024 20:29 — forked from strangerstudios/pmpromyCRED.php
Award MyCRED Points for membership check outs and renewals.
<?php
/**
* Add MyCRED points to whenever a user checksout for a PMPro Membership Level.
* Allows different points per membership level.
* Allows different points amount for membership renewals.
* Add this code below to your PMPro Customizations Plugin - http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* MyCRED can be downloaded/configured here: https://wordpress.org/plugins/mycred/
* Any questions, please feel free to visit www.paidmembershipspro.com
*/