Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
strangerstudios / my_pmpro_email_data.php
Created September 30, 2016 18:46
Make !!startdate!! and !!enddate!! available for all Paid Memberships Pro emails.
/*
Make !!startdate!! and !!enddate!! available for all PMPro emails.
Add this code to a custom plugin.
*/
function my_pmpro_email_data($data, $email) {
$user = get_user_by("login", $data['user_login']);
$level = pmpro_getMembershipLevelForUser($user->ID);
@andrewlimaza
andrewlimaza / my_custom_dashboards.php
Last active February 19, 2019 23:25
Show 'report' widgets within the admin dashboard
<?php
//Copy the code below into your PMPro Customizations plugin - http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
function add_my_report_dashboard(){
if( ! defined( 'PMPRO_DIR' ) || ! current_user_can( 'manage_options' ) ){
return;
}
wp_add_dashboard_widget(
'pmpro_membership_dashboard', // Widget slug.
@strangerstudios
strangerstudios / my_pmpro_invoice_address.php
Last active April 13, 2021 04:25
Add your business address and VAT number (if required) to the Membership Invoice and Membership Confirmation pages.
function my_pmpro_invoice_address() {
?>
<li><strong>Paid To:</strong><br />My Business<br />123 The Street<br />City, XX 12345 USA</li>
<?php
//<li><strong>VAT Number:</strong> BG999999999</li>
}
add_action('pmpro_invoice_bullets_bottom', 'my_pmpro_invoice_address');
<?php
//Address merge types must be handled in a very specific format
function my_pmpro_mailchimp_listsubscribe_fields($fields, $user)
{
$user_info = get_userdata($user->ID);
$new_fields = array(
"FNAME" => $user->first_name,
"EMAIL" => $user->email,
"LNAME" => $user->last_name,
@strangerstudios
strangerstudios / my_pmpro_mailchimp_listsubscribe_fields.php
Last active March 21, 2018 14:41
my_pmpro_mailchimp_listsubscribe_fields example for jslightham
/*
Sync fields to MailChimp
*/
function my_pmpro_mailchimp_listsubscribe_fields($fields, $user)
{
//get level
$level = pmpro_getMembershipLevelForUser($user->ID);
//get order
$order = new MemberOrder();
$order->getLastMemberOrder($user->ID);
@strangerstudios
strangerstudios / wp_head_account_number_js.php
Created June 27, 2016 21:09
Disable spaces and dashes in credit card fields on the PMPro checkout page.
/*
Disable spaces and dashes in credit card fields on the PMPro checkout page.
Add this code to your active theme's functions.php or a custom plugin.
This code may not work in all cases. It is:
* Adding JS into the <head> tag of your site (this makes sure it runs before Gateway JS)
* Only being added on the checkout and billing pages specified in the PMPro page settings (i.e. doesn't work if you have multiple checkout pages)
* Listening for when the #pmpro_form form is submitted.
* Changing the field with ID = "AccountNumber". Some gateways have different field ids and names.
@strangerstudios
strangerstudios / my_pmprorh_get_html.php
Created June 23, 2016 14:54
Add a button/etc after the "domain" register helper field.
/*
Add a button/etc after the domain register helper field.
Add this code to your active theme's functions.php or a custom plugin.
Edit the $html .= ... line below to the HTML you need. You may want to load any assocaited javascript separately.
*/
function my_pmprorh_get_html($html, $field) {
if($field->name == 'domain') {
$html .= '
<button name="mybutton">Check</button>
@strangerstudios
strangerstudios / pmpro_account_customized.php
Created June 20, 2016 20:00
Plugin to add a [pmpro_account_customized] shortcode to use instead of the regular one in Paid Memberships Pro
<?php
/*
Plugin Name: Customized PMPro Account Shortcode
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Add [pmpro_account_customized] shortcode.
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
@strangerstudios
strangerstudios / nextlastpayments.php
Last active August 31, 2021 21:21
Add last payment date and next payment date to the members list and export CSV in Paid Memberships Pro (PMPro)
/*
Add last paymenet date and next payment date to the members list and export CSV
Add this code into a custom plugin or your active theme's functions.php.
Note that "last payment" value will get the last order in "success", "cancelled", or "" status.
(Oddly enough, cancelled here means that the membership was cancelled, not the order.)
The "next payment" value is an estimate based on the billing cycle of the subscription and the last order date.
It may be off form the actual recurring date set at the gateway, especially if the subscription was updated at the gateway.
@andrewlimaza
andrewlimaza / change-default-checkout-button-pmpro.php
Last active November 7, 2024 06:17
Change default checkout button text for Paid Memberships Pro
<?php
//copy lines 5 - 20 to your active theme's functions.php or custom plugin. (edit line 11 to change text of button).
function my_pmpro_change_default_button_text( ){
global $pmpro_requirebilling;
?>
<span id="pmpro_submit_span">
<input type="hidden" name="submit-checkout" value="1" />
<input type="submit" class="pmpro_btn pmpro_btn-submit-checkout" value="<?php if($pmpro_requirebilling) { _e('Create Account', 'paid-memberships-pro'); } else { _e('Checkout and Continue', 'paid-memberships-pro');}?>" />