Skip to content

Instantly share code, notes, and snippets.

View davidmutero's full-sized avatar

David Mutero davidmutero

View GitHub Profile
@davidmutero
davidmutero / my-pmpro-move-user-field-group-after-billing.php
Last active May 2, 2025 08:55 — forked from dparker1005/my_pmpro_move_billing_fields.php
Move a User Field Group Below the Billing Address on PMPro Checkout
<?php
/**
* Move a specific user field group (e.g. Company Info) below the Billing Address on PMPro Checkout.
*
* This uses JavaScript to reposition any fieldset by targeting its ID.
* Update the `$fieldset_id` value to match the fieldset you want to move.
*
* 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.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
@davidmutero
davidmutero / my-pmproup-redirect-top-level-to-user-page.php
Last active April 24, 2025 13:48
Redirect Logged-In Users to Their Full Level User Page from the Top Level Parent Page
<?php
/**
* Redirect logged-in members visiting /top-level-page/ to their full user level page. Works best for single level setup.
* (e.g., /top-level-parent-page/username/user-page/) immediately, skipping the intermediate user page.
*
* This improves UX by automatically taking users to their specific level user page
* without requiring a second click.
*
* This recipe assumes the User Pages Add On is installed and configured.
* @link https://www.paidmembershipspro.com/add-ons/pmpro-user-pages/
@davidmutero
davidmutero / pmpro-redirect-to-specific-user-page.php
Last active April 23, 2025 13:22 — forked from ipokkel/pmpro-redirect-to-user-page.php
Plugin to work with PMPro and PMPro User Pages to redirect someone to their specific (with URL) user page on login
<?php
/**
* This recipe redirects members to their Specific (with URL) User Page on login
* and non-members to the PMPro membership levels page.
*
* This recipe assumes the User Pages Add On is installed and configured.
* @link https://www.paidmembershipspro.com/add-ons/pmpro-user-pages/
*
* 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.
@davidmutero
davidmutero / pmpro-template-redirect-after-checkout-discount-or-level.php
Last active April 11, 2025 12:17 — forked from kimwhite/pmpro-confirmation-url-redirect-with-discount-code.php
PMPro template_redirect redirection based on discount code OR membership level
<?php
/**
* This recipe will redirect users after checkout based on a Discount Code OR their Membership Level.
*
* It hooks into the `template_redirect` action and is useful when the default `pmpro_confirmation_url` filter
* does not work reliably, such as with off-site gateways like Stripe Checkout.
*
* 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:
@davidmutero
davidmutero / pmprosd_prorate_fixed_annual-delay.php
Last active April 10, 2025 13:59 — forked from kimwhite/pmprosd_prorate_delay.php
Custom proration billing amount plus initial amount for a level with a fixed renewal date (like “Y1-10-01”). Requires Subscription Delays Add On.
<?php
/**
* PMPro Customization: Prorate Initial Payment Based on Fixed Renewal Date. requires Subscription Delays Add On
*
* This recipe adjusts the initial payment for a membership level to reflect a prorated charge
* from the join date until a fixed annual renewal date (e.g., October 1).
* The membership level should have its Subscription Delay set to: `Y1-10-01`
*/
function my_pmprosd_prorate_delay( $level ) {
// Only apply to specific level ID(s) — update as needed.
@davidmutero
davidmutero / my-pmpro-members-list-level-group-columns.php
Created April 9, 2025 11:22
Add Level Group Columns in Members List CSV Export
<?php
/**
* Adds "Group One" and "Group Two" columns to the PMPro Members List CSV export.
* Each column includes level names based on static arrays of level IDs.
*
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_members_list_static_columns( $columns ) {
$columns['group_one'] = 'my_pmpro_get_group_one_column'; // Column title will be "Group One"
@davidmutero
davidmutero / pmpro-restrict-product-access-by-category-and-level.php
Last active April 7, 2025 12:02 — forked from andrewlimaza/pmpro_redirect_away_from_product_non_members.php
Restrict Direct Access to WooCommerce Products by Category and Membership Level with Paid Memberships Pro
<?php
/**
* This stops users from accessing restricted products directly with Paid Memberships Pro.
* Tested on WooCommerce 3.4 and up.
* You may be interested with the following gist for removing products from WooCommerce shop page - https://gist.github.com/andrewlimaza/6ee480694d38a99695503febe3cdabf1
* Add the following function to your PMPro Customizations plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Visit https://www.paidmembershipspro.com for any questions or assistance.
*/
@davidmutero
davidmutero / validate_select_user_field_in_pmpro_checkout.php
Last active March 12, 2025 17:14
Validate Select User field in PMPro Checkout
<?php
/**
* Validate a custom dropdown field in PMPro checkout to ensure a valid selection.
*
* In this gist, if the user selects the option ("SELECT ONE"), an error message is displayed.
* IMPORTANT - Remember you need to add this "default" option to your list of options in the select user field.
* The script attempts to retrieve the field's label dynamically for a more informative error.
*
* 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.
@davidmutero
davidmutero / my-pmpro-replace-checkout-member-donation-message.php
Last active March 10, 2025 13:23
Modify checkout message on restricted donation level for members switching
<?php
/**
* Modify the checkout message based on the "Donations-Only Level" setting.
*
* Ensures that existing members are only prevented from checking out with the donation-only level
* if the "Donations-Only Level" option is checked in the membership level settings.
*/
/**
*
@davidmutero
davidmutero / add-a-state-in-pmpro-state-dropdown-add-on.php
Created February 25, 2025 10:18
Add A State in PMPro State Dropdown Add On
<?php
/**
* Add a custom state/region to a specific country in the PMPro State Dropdown Add On.
*
* This ensures the new state/region appears in alphabetical order within the country's list.
* Modify `$country_code` and `$custom_state` as needed for your use case.
*
* 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: