Skip to content

Instantly share code, notes, and snippets.

View andrewlimaza's full-sized avatar

Andrew Lima andrewlimaza

View GitHub Profile
@andrewlimaza
andrewlimaza / user-fields-2-cols-example.php
Last active August 27, 2024 12:26
Make default "More Information" User Fields 2 columns Paid Memberships Pro
<?php
/**
* Make the "More Information" container for custom fields 2 columns at Paid Memberships Pro checkout.
* Tweak the code below to work for your needs and any other field group you may have.
* Follow this guide to add custom code to your WordPress site - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_custom_add_jquery_script() {
?>
<script type="text/javascript">
@andrewlimaza
andrewlimaza / pmpro-zapier-add-is-renewal-added-order.php
Created August 22, 2024 08:12
Add "is renewal" to PMPro Zapier (plugin) New Order outbound events.
<?php
/**
* Add 'is_renewal' to the data load sent to Zapier when using the New Order trigger for PMPro Zapier Add On.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_add_custom_field_added_order( $data, $order, $user_id ) {
if ( $order->is_renewal() ) {
$data['is_renewal'] = true;
} else {
$data['is_renewal'] = false;
@andrewlimaza
andrewlimaza / avoid-double-loading-select2-gamipress-leaderboard.php
Created August 20, 2024 07:20
Remove "select2" from Gamipress Leaderboard pages to avoid double loading.
<?php
/**
* Remove Paid Memberships Pro select2 from the GamiPress Leaderboard settings pages.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_custom_dequeue_select2() {
if ( isset( $_REQUEST['post_type'] ) && 'gp_leaderboard' == $_REQUEST['post_type'] ) {
wp_dequeue_script( 'select2' );
wp_deregister_script( 'select2' );
}
@andrewlimaza
andrewlimaza / wll-user-stats-custom-role-admin.php
Created August 19, 2024 17:37
When Last Login - User Statistics (Custom Role Filter)
<?php
/**
* Tweak the user capability required to view the When Last Login - User Statistics charts/reporting.
* This requires V1.1+ of When Last Login - User Statistics.
* Add this code to your site by following this guide - https://yoohooplugins.com/customize-wordpress/
*/
function my_wll_user_stats_admin_cap( $capability ) {
return 'edit_users'; // Change this to the custom capability value.
}
add_filter( 'wll_stats_access_cap', 'my_wll_user_stats_admin_cap', 10, 1 );
@andrewlimaza
andrewlimaza / pmpro-admin-disable-select-2.php
Last active August 19, 2024 10:50
Dequeue select2 in WordPress admin for non Paid Memberships Pro pages that may also be loading select2.
<?php
/**
* Remove select2.js and select2.css on non-pmpro pages to prevent conflicts within the WordPress admin.
* Only use this if you are 100% certain that the conflict is due to select2 being loaded more than once.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_custom_dequeue_select2() {
// Bail if we're on PMPro pages, but remove select2 from all other admin pages.
if ( ! empty( $_REQUEST['page'] ) && strpos( $_REQUEST['page'], 'pmpro' ) !== false ) {
@andrewlimaza
andrewlimaza / pmpro-check-orders-bulk-script.php
Last active August 15, 2024 09:13
Bulk update Check orders in Paid Memberships Pro to be "Success".
<?php
/**
* Inside the WordPress dashboard, as an administrator add the query ?check_order_success=1 to bulk update all pending check orders.
* Use this code with caution as it will update all instances.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_pbc_order_success_sql() {
global $wpdb;
if ( ! current_user_can( 'manage_options' ) ) {
@andrewlimaza
andrewlimaza / pmpro-pbc-set-to-success-status.php
Last active August 15, 2024 09:14
Paid Memberships Pro - Pay By Check automatically set to "success" status on purchase.
<?php
/**
* Supports Paid Memberships Pro V3.0.3+ and automatically sets the orders status to success when payment is done via check.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_pbc_order_success( $order ) {
// Do not run this code within the admin area, admins might be creating orders.
if ( is_admin() || ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'pmpro-orders' ) ) {
return;
@andrewlimaza
andrewlimaza / load-legacy-pmpro-content-message.php
Last active August 19, 2024 06:49
Add the option to load legacy content message.
<?php
/**
* Run this code _once_ and then remove it from your site. To run this code visit any page of the admin area.
* After visiting any admin page, you may delete this script from your site.
* This will add legacy logic to the content message for non-members.
*/
function my_pmpro_legacy_content_message() {
// Only logged-in admins can run this.
if ( ! current_user_can( 'manage_options' ) || ! empty( get_option( 'pmpro_nonmembertext' ) ) ) {
return;
@andrewlimaza
andrewlimaza / pmpro-give-access-to-posts-override-membership-restriction.php
Created May 8, 2024 07:40
Give non-members or visitors access to posts/shortcodes/blocks for specific post ID's
<?php
/**
* Bypasses all content restriction for posts, pages, blocks and shortcodes that are on certain pages.
* Tweak this code further for your 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_allowed_posts() {
$open_post_ids = array( 118 ); // Add all the POST ID's that you want to bypass here.
return $open_post_ids;
@andrewlimaza
andrewlimaza / pmpro-variable-pricing-recurring-text.php
Created May 8, 2024 01:51
Adjust Variable Pricing Add On Text for recurring levels.
<?php
/**
* Add recurring text after Variable Pricing text.
* Tweak the wording for your needs.
*
* To add this code to your site please visit - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_vp_text_adjustment( $text ) {
$level = pmpro_getLevelAtCheckout();