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 gets the payment plan associated with the level that is purchased
* and shows the relevant payment plan on the Membership Account page.
*
* This is used as a workaround when using the Payment Plans Add On only.
*
* 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.
@ipokkel
ipokkel / pmpro-fix-apostrophe-in-email-from-name-and-sitename.php
Created June 27, 2023 08:26
Replace double backslashes before apostrophe in the email From Name and replace apostrophe html code with an apostrophe in the sitename email placeholder variable.
<?php
/**
* Fix apostrophe's used in the from name and sitename email variable in emails.
*
* 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/
*/
@andrewlimaza
andrewlimaza / add-compatibility-for-sed-and-pmpro-woo.php
Created May 19, 2023 04:56
Add compatibility for PMPro Set Expiration Date Add On and PMPro WooCommerce Add On.
<?php
/**
* Support Set Expiration Date Add On for PMPro WooCommerce Add On.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmprowoo_set_expiration_date( $level_array ) {
// Make sure Set Expiration Date Add On is active.
if ( ! function_exists( 'pmpro_getSetExpirationDate' ) ) {
return $level_array;
@ipokkel
ipokkel / membership-expired-shortcode.php
Last active June 21, 2023 14:14
[membership_expired] shortcode
<?php
/**
* Add a shortcode to display content to members with an expired membership.
*
* Usage Example:
* [membership_expired]Shows if user's level expired[/membership_expired]
* [membership_expired level="1"]Shows if user's expired level ID matches[/membership_expired]
* [membership_expired levels="1, 2"]Shows if user's expired level ID matches one of the levels[/membership_expired]
*
* @param string $atts Shortcode level/levels IDs attributes.
@ipokkel
ipokkel / pmpro-sponsor-child.php
Created May 5, 2023 05:54
Display the sponsored users of a sponsor with a shortcode for PMPro Sponosored Members. [pmpro_sponsored_children]
<?php
/**
* Add a shortcode to display a list of sponsored children.
*
* @param array $atts {
* Attributes for the shortcode.
*
* @type int $user_id The user ID of the sponsor.
* }
*
<?php
/**
* Allow users with set custom roles access to the WordPress dashboard when users
* that also has a "Subscriber" role is being blocked if the Restrict Dashboard Access
* has been set on the Memberships > Settings > Advanced page.
*
* This should be helpful if users have multiple roles.
*
* 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.
<?php
/**
* Example of changing the group (location ) to add a user field to.
*
* "$where" locations available on the checkout page are:
* - after_pricing_fields
* - after_username
* - after_password
* - after_email
* - checkout_boxes
<?php
/**
* Allow users to add an avatar at checkout for the Basic User Avatars plugin.
*
* This recipe assumes that you have the Basic User Avatar plugin installed and activated.
* @link https://wordpress.org/plugins/basic-user-avatars/
*
* This recipe requires a custom user field created with the name basic_user_avatar.
* The field should be set to "No" for the display on the profile option for either
* the group (Show fields on user profile?) or the field (Show field on user profile?).
@ipokkel
ipokkel / toggle-payment-type-field-visibility-for-check.php
Created March 21, 2023 09:39
Show or hide (toggle) your check payment type user field group if the check payment option is selected. #pmpropbc #pmpro-pay-by-check
<?php
/**
* Toggle the Payment Type user field on the checkout page when using the Pay by Check gateway.
* The Payment Type field is moved to below the Choose Your Payment Method part on the checkout page.
*
* This is a partner recipe for the guide
* Let Users Select Offline Payment Methods Using the “Pay by Check” Gateway
* @link https://www.paidmembershipspro.com/let-users-select-offline-payment-methods-using-the-pay-by-check-gateway/
*
* This recipe assumes the following:
@dparker1005
dparker1005 / redirect_cancel_to_stripe.php
Created March 9, 2023 18:54
Redirect users from the cancellation page to the Stripe Customer Portal.
<?php
// Copy from below here...
/**
* Prevent users from cancelling their membership or checking out for a new one.
*/
function my_pmpro_redirect_cancel_to_stripe() {
global $pmpro_pages;
if ( ! empty( $pmpro_pages['cancel'] ) && is_page( $pmpro_pages['cancel'] ) ) {