Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Lima andrewlimaza

View GitHub Profile
@andrewlimaza
andrewlimaza / order.html
Created September 20, 2023 20:49
order.html sample for any language and encoding for Paid Memberships Pro PDF Invoices Non-English
View order.html
<style>
@font-face {
font-family: 'Noto Serif', serif;
src: url('https://fonts.googleapis.com/css2?family=Noto+Serif:wght@400;700&display=swap');
}
h1, p, table, span {
font-family: 'Noto Serif', serif;
}
#invoice, table{
@andrewlimaza
andrewlimaza / retroactively-enroll-members-learndash-pmpro.php
Last active September 15, 2023 13:34
Retroactively enroll members into LearnDash Courses that are restricted with PMPro.
View retroactively-enroll-members-learndash-pmpro.php
<?php
/**
* Retroactively enroll members into LearnDash courses via a cron job (or whenever you want to use this callback).
*
* Does batches of 50 members at a time that aren't enrolled and should be.
* Use a tool like WP Crontrol or manually set up a cron job for this callback to automatically run every couple of minutes or hours.
* Add this code to your custom plugin by visiting this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_courses_silent_enroll(){
global $wpdb;
@andrewlimaza
andrewlimaza / pmpro-payment-plan-select-plan-query-param.php
Created August 22, 2023 13:09
Select Paid Memberships Pro Payment Plan via query parameter
View pmpro-payment-plan-select-plan-query-param.php
<?php
/**
* Add &pmpropp_chosen_plan=<<plan_id>> in the URL to preselect the payment plan option.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_payment_plan_select_url() {
// Only load this on the checkout page.
if ( function_exists('pmpro_is_checkout') && !pmpro_is_checkout() ) {
return;
}
@andrewlimaza
andrewlimaza / admin-access-with-divi-pmpro-series.php
Created August 9, 2023 08:52
Give admin access to Series Add On with Divi
View admin-access-with-divi-pmpro-series.php
<?php
/**
* Give admins access to all series content when editing with Divi.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_series_give_admins_access_always( $hasaccess, $post, $user, $post_membership_levels ) {
if ( $hasaccess ) {
return $hasaccess;
}
@andrewlimaza
andrewlimaza / pmpro-update-jan-1999-to-never.sql
Created August 7, 2023 14:16
SQL update 1 January 1999 to 0000-00-00 for PMPro Members
View pmpro-update-jan-1999-to-never.sql
// Run this SQL query inside your database.
// Replace wp_ prefix with your actual table's prefix.
// ALWAYS HAVE A BACKUP BEFORE RUNNING ANY SQL DIRECTLY
UPDATE `wp_pmpro_memberships_users` SET `enddate` = '0000-00-00 00:00:00' WHERE `enddate` = '1999-01-01 00:00:00';
@andrewlimaza
andrewlimaza / my-load-shortcode-levels.php
Last active August 1, 2023 11:23
Load [pmpro_levels] shortcode even earlier for compatibility with Bricks and other builders that might need this.
View my-load-shortcode-levels.php
<?php
/**
* This registers [pmpro_levels] shortcode to be used in Bricks Builder.
* It can be tweaked for other shortcodes that _might_ not render with Bricks.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ (add it to a custom plugin)
*/
if ( ! shortcode_exists( 'pmpro_levels' ) ) {
add_shortcode("pmpro_levels",function(){
require_once( PMPRO_DIR . "/preheaders/levels.php" );
@andrewlimaza
andrewlimaza / pmpro-checkout-uf-radio-js-select.php
Created July 27, 2023 12:16
Preselect an option for a radio button on page load for User Fields and PMPro Checkout
View pmpro-checkout-uf-radio-js-select.php
<?php
/**
* Preselect a radio button option at PMPro Checkout sample.
* Please tweak this code further based on your own needs.
* To add this code to your site, please follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_checkout_js_script() {
// Only load this script on the checkout page.
if ( ! pmpro_is_checkout() ) {
return;
@andrewlimaza
andrewlimaza / cc-pmpro-admin-email-cancel.php
Created July 21, 2023 10:47
CC an email address on the 'cancel_admin' email PMPro sends out.
View cc-pmpro-admin-email-cancel.php
<?php
/**
* CC an email address on the 'cancel_admin' email PMPro sends out.
* Add this code to your site by following - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_email_headers_admin_cancel_emails($headers, $email) {
//cc emails already going to admin_email
if( $email->template == 'cancel_admin' ) {
//add cc
$headers[] = 'CC:' . 'otheremail@domain.com'; // type in your email address here please.
@andrewlimaza
andrewlimaza / pmpro-nav-buddyboss-buddypanel-menu-compat.php
Created July 17, 2023 10:31
Paid Memberships Pro - Nav Menu Add On support for BuddyBoss BuddyPanel member menus
View pmpro-nav-buddyboss-buddypanel-menu-compat.php
<?php
/**
* Overrides the default BuddyBoss menu attributes function as it only supported static menu names.
* This solves issues where the Nav Menu Add On is installed and wasn't showing the data-baloons (on hover).
*
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_bb_buddypanel_menu_atts( $atts, $item, $args ) {
// Make sure BuddyBoss is installed.
@andrewlimaza
andrewlimaza / pmpro-stripe-webhook-order-time-change.php
Last active July 19, 2023 06:56
Change order date of a recurring order whenever a subscription is processed.
View pmpro-stripe-webhook-order-time-change.php
<?php
/**
* Adjusts the orders date to line up with the date of the webhook transaction received from Stripe.
* For further assistance, please reach out to a local WordPress developer or tweak it for your needs.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_update_recurring_order_time( $order ) {
$order->timestamp = current_time( 'timestamp' );
$order->datetime = date( "Y-m-d H:i:s", $order->timestamp );
$order->saveOrder();