Skip to content

Instantly share code, notes, and snippets.

View dwanjuki's full-sized avatar

David Wanjuki dwanjuki

  • Nairobi, Kenya
  • 06:23 (UTC +03:00)
View GitHub Profile
@dwanjuki
dwanjuki / show_login_form.php
Last active May 28, 2024 13:52 — forked from andrewlimaza/show_login_form.php
Show login form instead of no access message when members are logged out
<?php
/**
* Show a simple login form if users are logged out and a post/page requires membership
*
* 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-directory-filter-by-user-meta.php
Last active May 8, 2024 13:28 — forked from ipokkel/pmpro-directory-filter-by-user-meta.php
Filter a certain PMPro Member Directory page results by user meta value
<?php
/**
* Filter a specific PMPro Member Directory page by custom user meta field.
*
* 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_directory_filter_based_on_user_meta( $sql_parts, $levels, $s, $pn, $limit, $start, $end, $order_by, $order ) {
@dwanjuki
dwanjuki / my_pmpro_user_fields_getfile.php
Last active May 9, 2024 09:25 — forked from ideadude/my_pmpro_getfile.php
Limit User Fields file uploads access to administrators and uploader
<?php
/*
* Restrict access to files uploaded via User Fields
* Allow access to only the file uploader and administrators
*
* Based on: https://www.paidmembershipspro.com/locking-non-wordpress-files-folders-paid-memberships-pro/
*
* 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.
@dwanjuki
dwanjuki / my_pmpro_checkout_prerequisite_level_checks.php
Last active October 7, 2024 12:46 — 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 / 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/
*/