Skip to content

Instantly share code, notes, and snippets.

View kimcoleman's full-sized avatar

Kim Coleman kimcoleman

View GitHub Profile
@kimcoleman
kimcoleman / paused_member_deny_pmpro_membership_access.php
Last active April 3, 2021 03:34
Mark a member "paused" and deny access to members-only content protected by Paid Memberships Pro.
<?php
/**
* Mark a member "paused" and deny access to members-only content.
* Show a message that the account is paused containing alink to the contact page.
*
* Requires Paid Memberships Pro and the Register Helper Add On.
*
*/
function my_pmprorh_init_pause_access() {
@kimcoleman
kimcoleman / my_pmpro_paypal_button_image.php
Last active February 10, 2025 16:35 — forked from strangerstudios/my_pmpro_paypal_button_image.php
Using the pmpro_paypal_button_image filter to change the PayPal button image on the PMPro checkout page.
<?php
/**
* Change the PayPal button image on the Paid Memberships Pro - Membership Checkout 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 my_pmpro_paypal_button_image( $url ) {
@kimcoleman
kimcoleman / my_pmpro_disable_member_emails.php
Last active April 14, 2021 03:30 — forked from strangerstudios/my_pmpro_disable_member_emails.php
Disable any email sent to the Member/User by Paid Memberships Pro
<?php
/**
* The function below will disable any email sent to the Member/User by Paid Memberships Pro.
* The admin emails will still be sent as intended.
*
* 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/
*/
@kimcoleman
kimcoleman / pmprorad_get_options.php
Created May 5, 2020 17:57
Get array of settings needed to make API calls.
<?php
/**
* Get array of settings needed to make API calls.
*
* Update the remotesite, APIUSER, and APIPASS settings
* as required for the remote site you will be testing against.
*/
function pmprorad_get_options() {
return array(
'localsite' => site_url(),
@kimcoleman
kimcoleman / my_pmpro_log_in_form_widget_avatar.php
Created May 7, 2020 11:18
Show the user's avatar before the menu area in the Log In Form widget for PMPro v2.3+
<?php
/**
* Show the user's avatar before the menu area in the Log In Form widget for PMPro v2.3+
*
*/
function my_pmpro_log_in_form_widget_avatar() {
global $current_user;
echo get_avatar( $current_user->ID, '80', '', $current_user->display_name );
}
add_action( 'pmpro_logged_in_welcome_before_menu', 'my_pmpro_log_in_form_widget_avatar' );
@kimcoleman
kimcoleman / redirect_non_members_to_levels_page.php
Last active April 3, 2021 03:11 — forked from andrewlimaza/redirect_users_to_a_new_page.php
Redirect non-members to the Membership Levels page in PMPro if they do not have a membership level.
<?php
/**
* Redirect non-members to the Membership Levels page if they do not have a 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/
*
*/
@kimcoleman
kimcoleman / pmpro_pmpro_not_logged_in_text_filter.php
Created May 14, 2020 11:07
Edit Teaser Messages Depending on Content
<?php
/**
* Edit Teaser Messages Depending on Content
*
*/
function pmpro_pmpro_not_logged_in_text_filter( $text ) {
global $post;
$access = pmpro_has_membership_access( $post->ID, NULL, true );
$level_ids = $access[1];
@kimcoleman
kimcoleman / bulk_update_pmpro_member_roles.php
Last active May 18, 2020 16:16
Bulk update all users with "subscriber" role to their membership level's custom role using the Roles for Membership Levels Add On.
<?php
/**
* Bulk update all users with "subscriber" role to their membership level's custom role.
* Loops through all users and checks their membership level. If level is set, checks if custom role for their level exists.
* Updates the role for all members excluding users with the $ignored_roles as defined in the array.
* This recipe is designed for sites that want to use the Roles for Membership Levels Add On on a site with existing members.
* Visit /?updateroles=1 when logged in as an admin to have existing users updated.
* Remove this code when finished.
*
**/
@kimcoleman
kimcoleman / my_login_redirect_per_membership_level.php
Created May 17, 2020 13:53
Redirect members on login to a specific page based on their level.
<?php
/**
* Redirect members on login to a specific page based on their 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/
*
*/
@kimcoleman
kimcoleman / block_dashboard_for_custom_role.php
Last active April 3, 2021 03:10
Block dashboard access for custom roles pmpro_role_1 and pmpro_role_2.
<?php
/**
* Block dashboard access for custom roles pmpro_role_1 and pmpro_role_2.
*
* 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/
*
*/