Skip to content

Instantly share code, notes, and snippets.

View andrewlimaza's full-sized avatar

Andrew Lima andrewlimaza

View GitHub Profile
@andrewlimaza
andrewlimaza / change-wp-login-in-email.php
Created April 16, 2024 06:53
Replace wp-login.php in WordPress emails to a custom login page via it's slug/permalink.
<?php
/**
* Replace wp-login.php with a custom slug in all WordPress emails where it's generated.
* Add this code to a custom plugin or a child theme's functions.php
*/
function my_replace_wp_login_in_emails($args) {
// Check if the message contains 'wp-login.php'
if (strpos($args['message'], 'wp-login.php') !== false) {
// Replace 'wp-login.php' with 'my-login'
$args['message'] = str_replace('wp-login.php', 'my-login', $args['message']); // change my-login to the slug of your choice
@andrewlimaza
andrewlimaza / enqueue-print-css-pmpro-theme-or-plugin.php
Created April 9, 2024 12:55
Enqueue custom print.css file for Paid Memberships Pro.
<?php
/**
* If anyone created a custom print.css file, add this code to a custom plugin to re-enqueue it in your theme or template directory.
*/
function my_enqueue_print_style() {
if ( file_exists( get_stylesheet_directory() . '/paid-memberships-pro/css/print.css' ) ) {
$print_css = get_stylesheet_directory_uri() . '/paid-memberships-pro/css/print.css';
} elseif ( file_exists( get_template_directory() . '/paid-memberships-pro/print.css' ) ) {
$print_css = get_template_directory_uri() . '/paid-memberships-pro/print.css';
} else {
@andrewlimaza
andrewlimaza / pmpro-customizations.php
Created March 22, 2024 08:24 — forked from indigetal/pmpro-spacesengine.php
Monetize SpacesEngine using Paid Memberships Pro and Selection of Addons. See link to accompanying tutorial in comments.
<?php
/*
Plugin Name: PMPro SpacesEngine Integration
Plugin URI: https://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Customizations for integrating Paid Memberships Pro with SpacesEngine
Version: 1.0
Author: Brandon Meyer
Author URI: https://collabanthnetwork.org
*/
@andrewlimaza
andrewlimaza / pmpro-approvals-added-to-members-list.php
Created March 20, 2024 14:02
Add approval status to members list of Paid Memberships Pro
<?php
/**
* Adds approval status column to the members list.
*
* @param [type] $columns
* @return void
*/
function my_pmpro_add_memberslist_col_approval( $columns ) {
$columns['approval'] = 'Approval Status';
return $columns;
@andrewlimaza
andrewlimaza / pmpro-non-approved-members-discount.php
Created March 20, 2024 09:58
PMPro remove discount for non-approved members and Woo
<?php
/**
* Adjust the Woo membership discount only if the member is approved.
* This won't discount for pending or denied members.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmprowoo_price_adjust_approvals( $discount_price, $lowest_price_level, $price, $product ) {
if ( ! class_exists( 'PMPro_Approvals' ) ) {
return $discount_price;
}
@andrewlimaza
andrewlimaza / pmpro-redirect-logged-in-people.php
Created March 18, 2024 13:48
Redirect logged-in people away from the login page of PMPro.
<?php
/**
* Redirect logged-in users away from the login page if already logged-in.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_login_page_redirect() {
global $pmpro_pages;
if ( is_page( $pmpro_pages['login'] ) && is_user_logged_in() ) {
wp_redirect( home_url( '/page-slug/' ) );
@andrewlimaza
andrewlimaza / echo-enqueued-styles-scripts-wordpress.php
Created March 8, 2024 07:19 — forked from omurphy27/echo-enqueued-styles-scripts-wordpress.php
Wordpress - Print Out All Enqueued Scripts And Styles On A Page
<?php
// add the below to your functions file
// then visit the page that you want to see
// the enqueued scripts and stylesheets for
function se_inspect_styles() {
global $wp_styles;
echo "<h2>Enqueued CSS Stylesheets</h2><ul>";
foreach( $wp_styles->queue as $handle ) :
echo "<li>" . $handle . "</li>";
@andrewlimaza
andrewlimaza / remove-sub-delay-pmpro.php
Last active March 5, 2024 09:14
Remove Subscription Delay for members and past members and set the initial price to the billing amount.
<?php
/**
* Remove the Subscription Delay for members and past members.
* This will change the price of the initial amount to the billing amount for past members.
* Tweak this code accordingly to your needs or hire a developer.
*
* To add this code to your site, please follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_one_time_sub_delay( $checkout_level ) {
@andrewlimaza
andrewlimaza / remove-custom-trial-for-members.php
Created March 4, 2024 14:50
Remove custom trial for levels for existing and past members Paid Memberships Pro (Trial only used once)
<?php
/**
* Removes custom trial for active and past members.
* Adjust this code accordingly to price your membership level when removing the trial.
* To add this code to your site, please follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_remove_custom_trial( $level ) {
if ( is_admin() || ! is_user_logged_in() ) {
return $level;
@andrewlimaza
andrewlimaza / add-order-payment-details-to-pmpro-pdf.php
Created February 15, 2024 19:05
Paid Memberships Pro PDF Invoices Plugin - Show card digits, expiration and order status.
<?php
/**
* Add custom variables to PDF template editor to show some more order information.
* To add this code to your site, please visit - https://yoohooplugins.com/customize-wordpress/
*/
function my_pmpro_pdf_card_details( $data_array, $user, $order_data ) {
$data_array['{{card}}'] = esc_html( $order_data->accountnumber );
$data_array['{{card_expiration}}'] = esc_html( $order_data->expirationmonth . '/' . $order_data->expirationyear );
$data_array['{{order_status}}'] = esc_html( $order_data->status );
return $data_array;