Skip to content

Instantly share code, notes, and snippets.

View kimcoleman's full-sized avatar

Kim Coleman kimcoleman

View GitHub Profile
@kimcoleman
kimcoleman / pmpro_pre23_login_redirect.php
Last active July 10, 2020 20:46
Login Redirect logic repurposed from previous version of PMPro released before 2.3+.
<?php
/**
* Login Redirect logic repurposed from previous version of PMPro released before 2.3+.
*
*/
function pmpro_pre23_login_redirect( $redirect_to, $request = NULL, $user = NULL ) {
global $wpdb;
//is a user logging in?
if ( ! empty( $user ) && ! empty( $user->ID ) ) {
@kimcoleman
kimcoleman / my_pmprommr_change_caps.php
Created July 7, 2020 19:31 — forked from dparker1005/my_pmprommr_change_caps.php
Changes membership manager so that they can only view the members list and add new members via PMPro Add Member.
<?php
// Copy from below here...
/*
* Changes membership manager so that they can only view
* the members list and add new members via PMPro Add Member.
*
* Can customize using your own caps from here:
* https://github.com/strangerstudios/pmpro-membership-manager-role/blob/35725b5cc9d7fd403255e4143a5bd5f1564b022d/pmpro-membership-manager-role.php#L16-L42
*/
@kimcoleman
kimcoleman / my_pmpro_element_class_buttons.php
Created July 7, 2020 13:25
Update all submit and link-type buttons in Paid Memberships Pro to use the CSS selector `button`.
<?php
/**
* Update all submit and link-type buttons in Paid Memberships Pro to use the CSS selector `button`.
*
* 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_element_class_buttons( $class, $element ) {
@kimcoleman
kimcoleman / block_admins_changing_membership_levels.php
Created July 2, 2020 12:07
Remove the membership dropdown from the edit profile page so that admins can't update a member's level.
<?php
/**
* Remove the membership dropdown from the edit profile page so that admins can't update a member's 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 / hide_my_pmpro_show_discount_code.php
Created July 2, 2020 12:00
Only show the discount code fields if a code is passed in via URL paramter
<?php
/**
* Only show the discount code fields if a code is passed in via URL paramter
*
* 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 hide_my_pmpro_show_discount_code( $show ) {
@kimcoleman
kimcoleman / my_restrict_my_pods_item_categories.php
Created June 25, 2020 19:22
Restricts content for the 'my_pods_item' CPT by category.
<?php
/**
* Restricts content for the 'my_pods_item' CPT by category.
* If a CPT has a category restricted by a membership, then run restricton code
* Please adjust the filter name to be 'pmpro_has_membership_access_filter_<<cpt_name>>'
*
* 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 / hide_my_pods_item_filter_post_types.php
Created June 25, 2020 19:21
Hide specific post types created using the Pods framework from searches and archives if membership is required to access.
<?php
/**
* Hide the 'my_pods_item' post type from searches and archives if membership is required to access.
* Update the $post_types[] array with one or more pod names you need to protect.
*
* 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 / hide_qpm_form_filter_post_types.php
Created June 25, 2020 19:09
Hide the 'qpm_form' post type from searches and archives if membership is required to access.
<?php
/**
* Hide the 'qpm_form' post type from searches and archives if membership is required to access.
*
* 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 hide_qpm_form_filter_post_types( $post_types ) {
@kimcoleman
kimcoleman / my_restrict_qpm_form_categories.php
Created June 25, 2020 19:09
Restricts content based on a CPT post's category.
<?php
/**
* Restricts content based on a CPT post's category.
* If a CPT has a category restricted by a membership, then run restricton code
* Please adjust the filter name to be 'pmpro_has_membership_access_filter_<<cpt_name>>'
*
* 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 / sample_pmproap_has_access.php
Created June 23, 2020 01:41
Check whether the current user has access to Addon Package with the post ID 15.
<?php
/**
* Check whether the current user has access to Addon Package with the post ID 15.
*
*/
global $current_user;
if ( pmproap_hasAccess( $current_user->ID, 12 ) ) { ?>
//Place your HTML or PHP code here if the user is in the required membership level
...
<?php }