Skip to content

Instantly share code, notes, and snippets.

View kimcoleman's full-sized avatar

Kim Coleman kimcoleman

View GitHub Profile
@kimcoleman
kimcoleman / my_pmpro_memberslist_extra_cols.php
Last active December 7, 2019 15:30 — forked from strangerstudios/my_pmpro_memberslist_extra_cols.php
Add a custom column to the Memberships > Members admin page for a user field added via Register Helper using the PMPro hook method.
<?php
/**
* Add a custom column to the Memberships > Members admin page for a user field
* added via Register Helper using the PMPro hook method.
*
* 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 / 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_mailchimp_listsubscribe_fields.php
Last active February 10, 2021 22:08 — forked from strangerstudios/my_pmpro_mailchimp_listsubscribe_fields.php
Example of using the pmpro_mailchimp_listsubscribe_fields filter to send extra fields to Mailchimp. The fields must be created in Mailchimp first, or you must used the pmpro_mailchimp_merge_fields filter to create them.
<?php
/**
* Sync additional user fields to Mailchimp.
* You must create the fields in Mailchimp first.
* Or, you can use the `pmpro_mailchimp_merge_fields` filter to create them through the API.
*
* 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 / my_pmpro_change_level_edd_update_payment_status.php
Last active March 13, 2021 19:20 — forked from andrewlimaza/change-level-edd.php
Change user's membership level when a product is purchased in Easy Digital Downloads.
<?php
/**
* This recipe will allow you to assign a membership level to members when purchasing an EDD product.
* You can do this one of two ways:
*
* OPTION 1: Product ID and Membership Level
* $product_levels = array(
27 => 1, //27 is the EDD product ID. 1 is the membership level they get when purchasing product 27
);
*
@kimcoleman
kimcoleman / show_gravatar_pmpro_account_bullets_top.php
Created February 11, 2021 01:19 — forked from strangerstudios/my_pmpro_account_bullets_avatars.php
Display a member's gravatar and a link to update at Gravatar on the Membership Account page "Profile" section.
<?php
/*
* Show a link to Gravatar and an avatar preview on the Profile section of the Membership Account 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_gravatar_pmpro_account_bullets_top() {
@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 / my_pmpro_checkout_level_extend_memberships.php
Last active April 3, 2021 03:45 — forked from strangerstudios/my_pmpro_checkout_level_extend_memberships.php
Allow membership level expiration date extensions for level changes.
<?php
/**
* Extend the membership expiration date for a member with remaining days on their current level
* when they complete checkout for ANY other level that has an expiration date.
* Always add remaining days to the enddate.
* Pulled in from: https://gist.github.com/3678054
*/
function my_pmpro_checkout_level_extend_memberships( $level ) {
global $pmpro_msg, $pmpro_msgt, $current_user;
@kimcoleman
kimcoleman / my_init_pmpro_mini_api.php
Last active April 3, 2021 03:51 — forked from strangerstudios/my_init_pmpro_mini_api.php
Very basic custom RESTful API to check the membership level of a Paid Memberships Pro User
<?php
/**
* Call to http://yoursite.com/?verify=email@domain.com&secret=SOMESECRETHERE to check the membership level of a user.
*/
function my_init_pmpro_mini_api() {
if ( function_exists( 'pmpro_getMembershipLevelForUser' ) &&
! empty( $_REQUEST[ 'verify' ] ) &&
! empty( $_REQUEST[ 'secret' ] ) )
{
if ( $_REQUEST[ 'secret' ] != 'SOMESECRETHERE' ) {
@kimcoleman
kimcoleman / pmpro-sponsored-members-assign-to-parent.php
Last active April 3, 2021 03:51 — forked from greathmaster/pmpro-sponsored-members-assign-to-parent.php
Retroactively assign a user to a Parent account when using the Sponsored Members Add On.
/**
* Retroactively assign a user to a Parent account when using the Sponsored Members Add On.
* Enter the user ID of parent account in the "Assign to Parent Account" on the "Edit Profile" screen.
*
* Note: The user's active Membership Level must be the correct "Child" level for that Parent/Child relationship.
*
*/
function pmprosm_assign_child_members( $profileuser ) {
if ( function_exists( 'pmprosm_getSponsor' ) && current_user_can( 'edit_users' ) ) {
@kimcoleman
kimcoleman / ninja_forms_field_membership_level.php
Last active April 4, 2021 03:55 — forked from ipokkel/ninja_forms_field_membership_level.php
Hidden Ninja Forms form field that captures PMPro membership level
<?php
/*
* Add a hidden field in Ninja Forms to capture Membership Level (if user is logged in).
*
* For Ninja Forms version 3 and higher.
*/
// Create Membership Level field for Ninja Forms
add_filter( 'ninja_forms_register_fields', function( $fields ) {
if ( class_exists( 'PMProMembershipLevelNFInput' ) ) {
$fields['pmpromembershiplevel'] = new PMProMembershipLevelNFInput;