Skip to content

Instantly share code, notes, and snippets.

View dwanjuki's full-sized avatar

David dwanjuki

  • Nairobi, Kenya
  • 19:20 (UTC +03:00)
View GitHub Profile
@dwanjuki
dwanjuki / my_pmpro_buddypress_profile_template_redirect.php
Last active July 4, 2024 08:19 — forked from kimwhite/my_pmpro_buddypress_profile_template_redirect.php
Redirect the PMPro Profile Edit and Password Reset pages to the user's BuddyPress Profile and Settings pages respectively
<?php
/**
* Redirect the PMPro Profile Edit and Password Reset pages
* to the user's BuddyPress Profile and Settings pages
*
* 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-add-welcome-name-to-menu.php
Last active June 24, 2024 12:17 — forked from kimwhite/pmpro-add-welcome-name-to-menu.php
Add member's name to Top Bar Nav menu location (OceanWP theme)
<?php
/**
* Add "Welcome, User Display Name" to the OceanWP Top Bar menu location
*
* 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-sub-delay-pmpro.php
Last active June 18, 2024 06:51 — forked from andrewlimaza/remove-sub-delay-pmpro.php
Remove Subscription Delay for members and past members and set the initial price to the billing amount.
<?php
/**
* Remove the Subscription Delay for members and past members
*
* This will change the price of the initial amount to the billing amount
* for past members of the level being checked out for
*
* This is an advanced customization recipe that may require further development
* to suit specific needs and/or setups. For more details, please see:
* https://www.paidmembershipspro.com/developers/
@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 / 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_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 / 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 ) {