Skip to content

Instantly share code, notes, and snippets.

View mircobabini's full-sized avatar

Mirco Babini mircobabini

View GitHub Profile
@mircobabini
mircobabini / my-pmpro-reset-cron-schedules.php
Last active March 11, 2022 17:26 — forked from sc0ttkclark/my-pmpro-reset-cron-schedules.php
Reset the Cron Schedules for Paid Memberships Pro. The single-use version can be found at: https://gist.github.com/sc0ttkclark/bd319a47656b786ccee3eca6f2dc4a9a
<?php
/**
* Reset the Cron Schedules for Paid Memberships Pro.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
<?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]
@mircobabini
mircobabini / pmpro-conpd-avoid-complete-cancellation.php
Last active January 16, 2025 17:45
PMPro snippet to disable the "Cancel" button when the auto-renew option is turned off.
<?php
/**
* Remove "Cancel" button for cancelled subscriptions.
*
* The user is still able to cancel auto-renew, but can't completely cancel the membership.
*/
add_filter( 'pmpro_member_action_links', function ( $pmpro_member_action_links ) {
global $current_user;
// bail if cancel link has been removed by someone else
@mircobabini
mircobabini / mainwp-add-child-info.php
Last active January 19, 2022 14:34 — forked from ragoand/mainwp-add-child-info
Add MainWP Child info and save
<?php
/**
* Code for MAINWP DASH
* Save information to the table {table_prefix}_mainwp_wp_options once the site is successfully synced
*
* @param mixed $pWebsite
* @param array $information
*
* @return void
@mircobabini
mircobabini / my_pmpro_forward_ipn.php
Last active October 5, 2021 16:16 — forked from andrewlimaza/my_pmpro_forward_ipn.php
Forward PMPro PayPal IPNs to another domain
<?php
/**
* Forward PMPro PayPal IPNs to another domain.
* Each domain will process the IPNs. The IPN handlers should be setup to ignore
* messages that aren't for that site. PMPro does this.
* This is useful if you have 2 different sites using the same PayPal account
* and the IPN is setup to go to a PMPro site.
* Add this to a custom plugin on the PMPro site the IPN hits.
* Update the domain/url to the IPN you want to forward to.
* The pmprodev_gateway_debug_setup check makes sure this DOESN'T run if you have the
@mircobabini
mircobabini / wp_dynsync.php
Last active May 17, 2021 12:26
BlogVault Real-Time Backups - add support for Paid Memberships Pro support (PMPro) => https://blogvault.freshdesk.com/support/tickets/46004
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('BVWPDynSync')) :
class BVWPDynSync {
public static $dynsync_table = 'dynamic_sync';
public $db;
public $settings;
<?php
/**
* PayPal Express only:
* Force pmpro_confirmed to be true in preheaders/checkout
* this way the user will be always created, even if the
* first payment was unsuccessful
*/
add_action( 'pmpro_checkout_confirmed', function ( $pmpro_confirmed, $morder ) {
if ( ! empty( $morder ) && ! empty( $morder->gateway ) && 'paypalexpress' === $morder->gateway ) {
<?php
/**
* Pluck a certain field out of each object in a list.
*
* This has the same functionality and prototype of
* array_column() (PHP 5.5) but also supports objects.
*
* @param array $list List of objects or arrays
* @param int|string $field Field from the object to place instead of the entire object
* @param int|string $index_key Optional. Field from the object to use as keys for the new array.
<?php
// ...
/* @var MemberOrder $last_order */
/* @var MemberOrder $old_order */
// Here we usually have $last_order or $old_order.
// I think that using the last order is something that we will dismiss soon or later.
// So I'm using $old_order later on.
<?php
/**
* Return all CSS class names for the specified element and allow custom class names to be used via filter.
*
* @since 2.3.4
*
* @param string|string[] $class A string or array of element class names.
* @param string $element The element to return class names for.
* @param ...string $args Extra elements or contexts to be considered.
*