Skip to content

Instantly share code, notes, and snippets.

View ideadude's full-sized avatar

Jason Coleman ideadude

View GitHub Profile
@ideadude
ideadude / my_pmpro_getfile.php
Last active May 7, 2024 09:39 — forked from strangerstudios/my_pmpro_getfile.php
How to protect non-WordPress files in a subdirectory of your site using Paid Memberships Pro.
<?php
/*
This code handles loading a file from the /protected-directory/ directory.
(!) Be sure to change line 19 below to point to your protected directory if something other than /protected/
(!) Be sure to change line 66 below to the level ID or array of level IDs to check for the levels you need.
(!) Add this code to your active theme's functions.php or a custom plugin.
(!) You should have a corresponding bit of code in your Apache .htaccess file to redirect files to this script. e.g.
###
@ideadude
ideadude / my_pmpro_category_filter.php
Last active April 14, 2024 16:18 — forked from strangerstudios/my_pmpro_category_filter.php
Add specific members-only categories back to main loop when filtering searches and archives.
<?php
/**
* Add specific members-only categories back to main loop
* when filtering searches and archives.
* Updated for PMPro 3.0+.
*
* 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/
@ideadude
ideadude / pmpro-cpt.php
Last active June 19, 2023 22:43 — forked from strangerstudios/pmpro-cpt.php
Add the PMPro meta box to a CPT. Add this to your plugin/etc.
<?php
/**
* Add the PMPro meta box to a CPT
*/
function my_add_pmpro_meta_box_to_cpts() {
// Duplicate this row for each CPT. This one adds the meta boxes to 'product' CPTs.
add_meta_box('pmpro_page_meta', 'Require Membership', 'pmpro_page_meta', 'product', 'side' );
}
add_action( 'admin_menu', 'my_add_pmpro_meta_box_to_cpts', 20 );
@ideadude
ideadude / my_pmpro_additional_categories.php
Created October 19, 2022 09:59 — forked from strangerstudios/my_pmpro_additional_categories.php
Add "Purchase Additional Access" box to Membership Checkout for a la carte category purchase.
<?php
/**
* Require specific category user meta to view posts in designated categories.
* Custom price-adjusting fields are added via user fields.
* The initial payment and billing amount is adjusted based on cat selections.
*
* 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/
@ideadude
ideadude / pmpro-australia-gst.php
Last active January 19, 2023 09:27 — forked from strangerstudios/pmpro-australia-gst.php
Paid Memberships Pro - Australia GST
<?php
/*
Plugin Name: Paid Memberships Pro - Australia GST
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-australia-gst/
Description: Apply Australia GST to Checkouts with PMPro
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
/*
@ideadude
ideadude / pmpro_queries.sql
Last active October 24, 2022 21:22 — forked from strangerstudios/pmpro_queries.sql
Some queries around PMPro sales/etc
# successful paid orders for a given month
SELECT COUNT( * )
FROM wp_pmpro_membership_orders
WHERE
total > 0 AND
status NOT IN (
'error', 'token', 'refunded', 'pending', 'review'
)
AND TIMESTAMP > '2017-10-01'
AND TIMESTAMP < '2017-11-01';
@ideadude
ideadude / add-billing-to-add-member-and-profile.php
Last active August 25, 2022 17:31 — forked from andrewlimaza/add-billing-to-add-member-and-profile.php
Add billing fields to Add Member Settings
<?php
/*
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* This will add billing fields to Add Member and the user's profile page.
*/
function add_billing_fields_to_add_member_profile() {
//check for register helper
if(!function_exists("pmpro_add_user_field")) // pmprorh_add_registration_field
return;
@ideadude
ideadude / my_pmprorh_init.php
Last active August 19, 2022 17:01 — forked from strangerstudios/my_pmprorh_init.php
Register Helper Example
<?php
/*
* Example Register Helper fields for Company, Referral Code, and Budget.
*
*/
// We have to put everything in a function called on init, so we are sure Register Helper is loaded.
function my_pmprorh_init() {
// Don't break if Register Helper is not loaded.
if ( ! function_exists( 'pmprorh_add_registration_field' ) ) {
@ideadude
ideadude / my_pmpro_registration_checks_restrict_email_addresses.php
Last active July 6, 2022 11:01 — forked from strangerstudios/my_pmpro_checkout_restrict_email_domain.php
Restrict Membership Signup by Email Domain (Useful for Education, Corporate, or Association Memberships)
<?php
/**
* Restrict Membership Signup by Email Domain
* Make sure to edit the $valid_domains array defined further below
* to include only the domains you'd like to allow.
*
* Add this code to a custom plugin. More info: https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_registration_checks_restrict_email_addresses( $value ) {
$email = $_REQUEST['bemail'];
@ideadude
ideadude / automatically-approve-previously-approved.php
Created December 3, 2021 14:36 — forked from travislima/automatically-approve-previously-approved.php
Automatically approve, previously approved members. [Paid Memberships Pro]
<?php
/**
* Automatically approve any previously approved member.
* Requires the PMPro Approval Process for Membership Add On - https://www.paidmembershipspro.com/add-ons/approval-process-membership/
* Add this code to your site following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_automatically_approve_previously_approved( $level_id, $user_id, $cancelled_level ) {
if ( ! class_exists( 'PMPro_Approvals' ) ) {