Skip to content

Instantly share code, notes, and snippets.

View MaryOJob's full-sized avatar
🏠
Working remotely 😈

Mary Job MaryOJob

🏠
Working remotely 😈
View GitHub Profile
<?php //do not copy
/**
* This recipe set the default level on the checkout page to the member's current level
*
* 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/
*/
<?php
/**
* Hides empty elements on the directory and profile pages.
*
* Can be useful if you have a select type user field
* and you don't want to display them if they are empty.
* This requires the first select field option to be configured
* with no value set, a colon, and a label set. e.g. ":label".
*
* For example:
<?php //do not copy
/**
* This recipe gets a customer's Tax ID and country from the webhook
*
* Create two User fields with the names pmpro_stripe_tax_type and pmpro_stripe_tax_id to view
* the tax type and tax ID in the member's profile.
*
* 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.
@kimcoleman
kimcoleman / my_update_existing_user_nicenames.php
Created April 8, 2025 14:51
One-time update: Set user_nicename to a safe "first-name-last-name" format for existing users.
/**
* One-time update: Set user_nicename to a safe "first-name-last-name" format for existing users.
*/
function my_update_existing_user_nicenames() {
// Only run for admins to avoid performance hits or unauthorized access.
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
// Add a transient so we only run this once.
@kimcoleman
kimcoleman / my_set_safe_user_nicename.php
Created April 8, 2025 14:47
Filter the user nicename to use a sanitized first-name-last-name format.
<?php
/**
* Filter the user nicename to use a sanitized first-name-last-name format.
*/
function my_set_safe_user_nicename( $nicename ) {
if ( ! isset( $_POST['first_name'] ) || ! isset( $_POST['last_name'] ) ) {
return $nicename;
}
$first_name = sanitize_text_field( $_POST['first_name'] );
@dwanjuki
dwanjuki / my_pmpro_add_order_details_to_email.php
Last active May 2, 2025 16:38 — forked from andrewlimaza/add-invoice-details-to-email-pmpro.php
Add subtotal (!!invoice_subtotal!!) and tax (!!invoice_tax!!) variables to email templates
<?php // copy from below
/**
* Add !!invoice_subtotal!! and !!invoice_tax!! variables to email templates where an Order ID is available.
*
* 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/
*/
function my_pmpro_add_order_details_to_email( $data, $email ) {
@dwanjuki
dwanjuki / my_pmpro_group_account_removal_notification.php
Created December 18, 2024 13:23
Send email to user when removed from a group account via the Manage Group page
<?php
/**
* Send email to user when removed from a group account via the Manage Group page
*
* 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
/**
* Add a "Total Memberships" column to the Members List and Users List.
*
* 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/
*/
// Add 'Total Memberships' Column to Members columns.
<?php
/**
* Add donation email vairable and reset membership cost value to exclude donation.
*
* 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/
*/
function my_pmpro_email_data_membership_cost_donation( $data, $email ) {
@dwanjuki
dwanjuki / my_get_avatar_url.php
Created November 28, 2024 08:50
Filter the output of the the get_avatar_url function to use our local avatar
<?php
/**
* Filter the output of the the get_avatar_url function to use our local avatar
*
* Guide: https://www.paidmembershipspro.com/custom-user-avatars-member-profile-edit-page/
*
* 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/