Skip to content

Instantly share code, notes, and snippets.

View travislima's full-sized avatar

Travis Lima travislima

View GitHub Profile
@travislima
travislima / my_gettext_membership.php
Last active May 22, 2018 12:04 — forked from andrewlimaza/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;
}
@travislima
travislima / replace_spaces_with_underscores.php
Last active August 8, 2018 15:11 — forked from andrewlimaza/replace_spaces_with_underscores.php
Replace spaces with underscore "_" for usernames.
<?php // Do not copy this tag.
/**
* 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'] );
@travislima
travislima / shortcode_membership_name.php
Last active September 4, 2018 11:52 — forked from andrewlimaza/shortcode_membership_name.php
Membership level name shortcode for Paid Memberships Pro
<?php //Do not copy this tag.
// Copy the function below into your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
// Use the shortcode [membership_level] to display the user's current membership level.
function pmpro_membership_level_shortcode( $atts ){
if(is_user_logged_in() && function_exists( 'pmpro_hasMembershipLevel' ) && pmpro_hasMembershipLevel()){
global $current_user;
$current_user->membership_level = pmpro_getMembershipLevelForUser($current_user->ID);
return sprintf(__( "Your current level is: %s", "pmpro" ), $current_user->membership_level->name);
@travislima
travislima / my-pmpro-applydiscountcode-return-js.php
Last active February 5, 2019 10:37 — forked from messica/my_pmpro_applydiscountcode_return_js.php
Display messages of the Original Price, Discounted Price and Amount Saved when discount code is applied to PMPro order.
<?php
/**
* Display messages of the Original Price, Discounted Price and Amount Saved when discount code is applied to PMPro order.
* Add this code recipe to a PMPro Customization Plugin - Display messages of the Original Price, Discounted Price and Amount Saved when discount code is applied to PMPro order
* Various classes added to strings to allow for styling - ".pmpro-discorig-message", ".pmpro-orginal-price", ".pmpro-discount-price", ".pmpro-save-price"
*
* [my_pmpro_applydiscountcode_return_js] Display original price and discount when a discount code is applied.
* @param string $discount_code [description]
* @param integer $discount_code_id [description]
@travislima
travislima / next_payment_date_account.php
Created August 20, 2019 11:30 — forked from andrewlimaza/next_payment_date_account.php
Show next payment date under the 'Expiration' field in the PMPro Account Page
<?php
/**
* Show next payment date under 'Expiration' field in PMPro account page.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Works for PayPal Express and Stripe payment gateways.
* www.paidmembershipspro.com
*/
// Change the expiration text to show the next payment date instead of the expiration date
// This hook is setup in the wp_renewal_dates_setup function below
function my_pmpro_expiration_text($expiration_text) {
@travislima
travislima / my_pmprorh_init.php
Last active February 6, 2020 10:44 — forked from ideadude/my_pmprorh_init.php
Register Helper Field Example - Incomplete Code
<?php
/*
* Example of Register Helper fields. Code is incomplete. For complete coding solution, please see: https://www.paidmembershipspro.com/documentation/register-helper-documentation/code-examples/
*
*/
// Define the fields.
$fields = array();
$fields[] = new PMProRH_Field(
'company', // input name, will also be used as meta key
@travislima
travislima / my_pmpro_add_addtional_field_to_register_helper.php
Last active February 6, 2020 11:15 — forked from MaryOJob/my_pmpro_add_addtional_field_to_register_helper.php
Already have Register Helper Fields Created and want to Add more fields to it - Use this script to Add to existing Customization
<?php
/**
* Requires Paid Memberships Pro and the PMPro Register Helper Add On(https://www.paidmembershipspro.com/add-ons/pmpro-register-helper-add-checkout-and-profile-fields/) to be installed and activated in order to work
* Please only add this script if you have previously added a custom field to your Register Helper and you need to add another field.
*/
$fields[] = new PMProRH_Field(
'field_name', // input name, will also be used as meta key
'text', // type of field
@travislima
travislima / pmpro-south_african-vat.php
Last active April 24, 2020 15:59 — forked from strangerstudios/pmpro-australia-gst.php
Paid Memberships Pro - South African VAT Plugin (DEVELOPING)
<?php
/*
Plugin Name: Paid Memberships Pro - South Africa VAT
Plugin URI: TBA
Description: Apply South Africa VAT to Checkouts with PMPro
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
/*
@travislima
travislima / generate-field-data-for-specific-levels.php
Created February 19, 2019 11:08 — forked from andrewlimaza/generate-field-data-for-specific-levels.php
Generate fields for free membership levels, or specific levels.
<?php
/**
* This will generate information for username, password and password 2. This is great for free levels.
* Adjust the $generate_data_level ID's to allow data generation for specific levels.
* Use CSS to hide these fields on the checkout page from the frontend.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
// Function to make fields optional for free levels.
function my_generate_fields_for_users() {
@travislima
travislima / my_init_email_as_username.php
Created August 21, 2018 09:28 — forked from strangerstudios/my_init_email_as_username.php
Use the email address as username with PMPro checkout. You'll also have to hide the username fields at checkout using CSS or a custom checkout page template.
<?php
function my_init_email_as_username()
{
//check for level as well to make sure we're on checkout page
if(empty($_REQUEST['level']))
return;
if(!empty($_REQUEST['bemail']))
$_REQUEST['username'] = $_REQUEST['bemail'];