Skip to content

Instantly share code, notes, and snippets.

View dwanjuki's full-sized avatar

David dwanjuki

  • Nairobi, Kenya
  • 05:38 (UTC +03:00)
View GitHub Profile
@dwanjuki
dwanjuki / my_pmpro_checkout_redirect_non_renewals.php
Created April 29, 2024 09:29
Allow only renewals on checkout page
<?php // copy from below
/*
* Redirect users who aren't renewing a membership away from checkout
*
* 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/
*
*/
@dwanjuki
dwanjuki / my_pmpro_enforce_prerequisite_level.php
Last active April 29, 2024 09:58 — forked from dparker1005/mmpu_prerequisite_levels.php
Require user to have a prerequisite level before purchasing a restricted level
<?php // copy from below
/*
* Require user to have a prerequisite level before purchasing a restricted 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/
*
*/
@dwanjuki
dwanjuki / my_pmpro_subsite_require_membership_level.php
Created April 26, 2024 07:45
Limit subsite access to specific membership levels
<?php // copy from below
/**
* This recipe redirects members without the specified levels away from subsite pages
* to a page on the main network site
*
* This recipe has to be added to a customization plugin that is only active
* on a subsite where you would like to enforce this redirection (Not network activated)
*
* Read this companion article for step-by-step directions:
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/#method-2
@dwanjuki
dwanjuki / my_pmpro_members_list_initial_payment_column.php
Created April 23, 2024 12:42
Add Initial Payment column to PMPro v3 Members List Export CSV
<?php
/**
* Add Initial Payment to Members List Export CSV
*
* 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/
*
*/
@dwanjuki
dwanjuki / my_pmpro_courses_archive_posts_per_page.php
Created April 18, 2024 06:40
Change number of courses shown on the PMPro Courses Archive page
<?php // do not copy this line
/**
* Show all courses on the PMPro Courses Archive 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/
*
*/
@dwanjuki
dwanjuki / pmpro-limit-members-per-level.php
Last active April 16, 2024 09:30 — forked from strangerstudios/pmpro-limit-members-per-level.php
Limit the number of total sign ups for a given membership level
<?php
/*
Set a maximum number of members allowed to register for a membership level.
Add this code to a plugin for PMPro Customizations.
Set the "Maximum" for a level on the Memberships > Membership Levels > Edit Level admin page.
*/
function pmproml_pmpro_save_membership_level( $level_id) {
if( $level_id <= 0 ) {
@dwanjuki
dwanjuki / pmpro_show_spots_available.php
Last active April 16, 2024 09:26 — forked from kimcoleman/pmpro_show_spots_available.php
Show number of spots available for a membership level Paid Memberships Pro.
<?php
/**
* This will show '0/X spots available.' on membership level if a limit is set from (https://www.paidmembershipspro.com/limit-number-members-membership-level/)
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* For help, post a support thread on www.paidmembershipspro.com
*/
function pmpro_show_spots_available( $expiration_text, $level ) {
global $wpdb;
@dwanjuki
dwanjuki / my_login_change_text_with_gettext.php
Created April 11, 2024 14:06
Change / Translate login page text strings with the gettext filter
<?php // do not copy this line
/**
* This recipe changes login page text strings with the gettext filter
*
* 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/
*/
@dwanjuki
dwanjuki / pmpro-discount-code-for-membersonly.php
Last active April 11, 2024 09:05 — forked from kimwhite/pmpro-discount-code-for-membersonly.php
Discount Code for Members of Certain Levels Only
<?php // do not copy this line.
/**
* Restrict discount code usage to members of certain 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/
*/
@dwanjuki
dwanjuki / pmpro_is_downgrade_custom_filter.php
Last active April 10, 2024 13:01
Treat changes from level 1 to level 2 as an upgrade when prorating
<?php
/**
* Treat changes from level 1 to level 2 as an upgrade when using the Proration Add On
*
* 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_is_downgrade_custom_filter( $is_downgrade, $old_level_id, $new_level_id ) {