Skip to content

Instantly share code, notes, and snippets.

View dwanjuki's full-sized avatar

David dwanjuki

  • Nairobi, Kenya
  • 18:12 (UTC +03:00)
View GitHub Profile
@dwanjuki
dwanjuki / sell-courses-addon-packages.php
Last active June 6, 2024 07:43 — forked from kimwhite/sell-courses-addon-packages.php
Sell PMPro Courses through AddOn Packages
<?php
/**
* Adds the AddOn Package post meta to 'pmpro_course' post type.
* Give access if they purchased "Courses" parent container.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function add_pmpro_courses_to_AP( $types ) {
$types[] = 'pmpro_course';
<?php
/**
* This recipe logs out non-approved members after checkout.
*
* Requires PMPro Approvals - pmpro-approvals
* https://www.paidmembershipspro.com/add-ons/approval-process-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.
@dwanjuki
dwanjuki / my_pmpro_user_login_focus_preventscroll.php
Created May 30, 2024 08:36
Prevent focus scrolling to the PMPro frontend login form on page load
<?php // copy from below
/**
* Prevent scrolling to the PMPro frontend login form on page load
*
* 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 / 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 / my_pmpro_ca_tax.php
Created May 17, 2024 10:40
Adds 5% tax if billing address is in Canada
<?php
/**
* Adds 5% tax if billing address is in Canada
*
* 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_memberlite_pmpro_courses_columns_ratio.php
Last active May 16, 2024 12:27
Make Courses and Lessons pages full width when using Memberlite & PMPro Courses Default Module
<?php
/**
* Make Courses and Lessons pages full width when using
* Memberlite & the PMPro Courses Default Module
*
* 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_level_checkout_page_title.php
Last active May 13, 2024 06:45
Change page title for specific level checkouts
<?php
/**
* Change page title for specific level checkouts
*
* 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_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/
*
*/