Skip to content

Instantly share code, notes, and snippets.

View dwanjuki's full-sized avatar

David Wanjuki dwanjuki

  • Nairobi, Kenya
  • 04:27 (UTC +03:00)
View GitHub Profile
@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 / pmpro-discount-code-for-membersonly.php
Last active October 28, 2024 13:41 — 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_register_redirect.php
Last active April 9, 2024 10:23 — forked from strangerstudios/pmpro_register_redirect.php
Disable the PMPro redirect from default WordPress register page to PMPro levels page.
<?php
/**
* Disable the PMPro redirect from default WordPress register page to PMPro levels 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/
*/
add_filter('pmpro_register_redirect', '__return_false');
@dwanjuki
dwanjuki / pmpro-defult-country-code.php
Last active March 27, 2024 13:57 — forked from kimwhite/pmpro-defult-country-code.php
Set a default billing country and VAT country
<?php // do not copy this line.
/**
* This recipe sets a default billing country and VAT country
*
* 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 / mypmpro-geocode-users-only.php
Last active February 29, 2024 09:15 — forked from JarrydLong/mypmpro-geocode-users-only.php
This recipe will geocode users based on their WooCommerce billing address
<?php
/**
* This recipe will geocode users based on their WooCommerce billing address.
* Run /wp-admin/?pmpromm_process_users=true to run the script.
*
* 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 / remove_confirm_email.php
Last active February 23, 2024 13:27 — forked from kimwhite/remove_confirm_email_password.php
Remove the "Confirm Email" field on checkout page
<?php
/**
* This recipe will remove the "Confirm Email" field on 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 / gettext-multiple-memberships-per-user-with-context.php
Last active February 19, 2024 09:50 — forked from kimwhite/gettext-multiple-memberships-per-user.php
Change or translate text strings for PMPro Multiple Memberships Per User.
<?php
/**
* Change or translate text strings for PMPro Multiple Memberships Per User.
*
* This recipe assumes and requires that both PMPro core and PMPro Multiple Memberships Per User are active.
*
* 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 / period_to_lock_member_only_content_per_membership_level.php
Created February 12, 2024 15:02 — forked from ipokkel/period_to_lock_member_only_content_per_membership_level.php
Lock membership content for an additional period. This is handy for memberships that should have access to a members-only post after a certain time has passed depending on their level. E.g. Gold level has immediate access, silver has access after 7 days and bronze after one month the post was published.
<?php
/**
* Set a waiting period before unlocking a members-only post that
* the member's membership level has access to.
*
* To set which posts to unlock and their individual period (days)
* set the post id's as the array key and the period as the
* value of the array key of the $posts_to_unlock variable.
*
* You can add this recipe to your site by creating a custom plugin
@dwanjuki
dwanjuki / pmpro-signup-shortcode-gettext-.php
Last active February 5, 2024 11:50 — forked from ipokkel/pmpro-signup-shortcode-gettext-example.php
Translate or change a text string in the PMPro Signup Shortcode
<?php
/**
* Translate or change a text string in the PMPro Signup Shortcode.
*
* 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_signup_shortcode_gettext( $translated, $text, $domain ) {