Skip to content

Instantly share code, notes, and snippets.

View ipokkel's full-sized avatar

Theuns Coetzee ipokkel

View GitHub Profile
@ipokkel
ipokkel / pmpro-change-recipient-for-billing-emails.php
Created April 25, 2024 07:05
Change the email recipient for a specified set of email templates if the intended recipient has an alternative recipient email address set as user meta.
<?php
/**
* Change the recipient for billing emails to an additional email address.
*
* 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_change_recipient_for_billing_emails( $user_email, $email ) {
@ipokkel
ipokkel / pmpro-3-cancel-immediately.php
Created April 18, 2024 09:21
Cancel a membership level immediately instead of setting the expiration date until the next payment date.
<?php
/**
* Cancel an automatically recurring payment membership level immediately
* when a user cancels their membership 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.
* 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 gateway column to the member edit orders 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/
*/
@ipokkel
ipokkel / show-pmpro-shipping-address-fields-on-member-edit.php
Created April 12, 2024 07:31
Show and edit the Shipping Address fields on the Member Edit page for PMPro 3.0 and newer.
<?php
/**
* Show PMPro shipping address fields on the member 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/
*/
function show_pmpro_shipping_address_fields_on_member_edit() {
@ipokkel
ipokkel / add-html-attributes-to-pmpro-user-fields.php
Created April 8, 2024 08:44
Add html attributes to a custom PMPro user field created in settings.
<?php
/**
* Add HTML attributes to PMPro user fields.
*
* 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 add_html_attributes_to_pmpro_user_fields( $field, $where) {
@ipokkel
ipokkel / pmpro-login-redirect-admin-and-users.php
Created April 5, 2024 08:21
Redirect administrators and membership manangers to the WP Admin Dashboard and other users to the membership account page on login.
<?php
/**
* Redirect Administrators and Membership Managers to WP Admin,
* redirect other users to the account page after login.
*
* 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
/**
* Allow admins to access posts for specific membership levels.
*
* 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 pmpro_allow_access_for_admins_for_set_levels( $hasaccess, $post, $user, $post_membership_levels ) {
@ipokkel
ipokkel / pmpro-hide-admin-membership-access-toolbar.php
Created April 4, 2024 11:22
Hide the PMPro admin "View As" selector from the WordPress Toolbar.
<?php
/**
* This will hide the Membership Access Toolbar from the WordPress Admin Bar.
*
* 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_filter( 'pmpro_hide_admin_membership_access_toolbar', '__return_true' );
<?php
/**
* Hide the email address from the member directory.
*
* 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 remove_user_email_address_from_member_profile( $value, $original_value, $field_name ) {