Skip to content

Instantly share code, notes, and snippets.

View indigetal's full-sized avatar

Brandon Meyer indigetal

  • The Collaborative Anthropology Network
  • NC
View GitHub Profile
@indigetal
indigetal / my_pmpro_custom_redirects.php
Last active August 8, 2023 02:44
Works with PMPro and the Multiple Memberships Per User Addon. Create 2 membership plan pages using Advanced Levels Page Shortcode Addon for 2 level groups, called group 1 and group 2 here. Redirects users to the relevant membership plan page if the user does not have the membership level that corresponds to the restricted page. Allows users to p…
<?php
// Restrict access to certain pages based on level group:
function my_pmpro_custom_redirects() {
// The Level ID's associated with each "Level Group"
$group_one = array('1', '2', '3');
$group_two = array('4', '5', '6');
// The pages to be restricted
$page_names = array('group-1-access', 'group-2-access');
@indigetal
indigetal / my_pmpro_adjustable_level_cost_v1.4.php
Last active August 4, 2023 16:22
For Paid Memberships Pro - Adjusts the cost of a level at checkout based on the selection of a custom user field for upselling additional options to a plan and accounts for recurring plans (fixes and expands on the code snippet at https://www.paidmembershipspro.com/multiple-membership-levels-per-user-pmpro-workarounds/)
<?php
function my_pmpro_adjustable_level_cost($level)
{
// Set the field name here
$field_name = 'field_name';
// Set the available field options and their extra fee here
$options = array(
'option1' => 100,
'option2' => 200,
@indigetal
indigetal / my_pmpro_adjustable_level_cost_v1.5.php
Last active August 4, 2023 16:22
For Paid Memberships Pro - Adjusts the cost of a level at checkout based on the selection of a custom user field for upselling additional options to a plan, accounts for recurring plans, and adjust the cost based on if it's a monthly or annual plan (fixes and expands on the code snippet at https://www.paidmembershipspro.com/multiple-membership-l…
<?php
function my_pmpro_adjustable_level_cost($level)
{
// Specify the monthly and annual levels
$monthly_levels = array(1, 2);
$annual_levels = array(3, 4);
// Set the field name here
$field_name = 'field_name';
@indigetal
indigetal / my_pmpro_adjustable_level_cost_v1.1.php
Last active August 9, 2023 15:31
The PMPro code snippet in https://www.paidmembershipspro.com/multiple-membership-levels-per-user-pmpro-workarounds/ does not work as-is. It is a very simple premise, only checking for one option. Recurring payments do not work the way it was originally written either. This does the same thing using a checkbox and only allowing for a one-time pay…
<?php
function my_pmpro_adjustable_level_cost($level)
{
if(isset($_REQUEST['field_name']))
{
$level->initial_payment = $level->initial_payment + 100; //specify the cost of the selected option
// You cannot update recurring payments with this code as-is, see comment below
}
return $level;
@indigetal
indigetal / my_pmpro_adjustable_level_cost_v1.2.php
Last active August 4, 2023 16:20
For Paid Memberships Pro - Adjusts the cost of a level at checkout based on the selection of a custom user field checkbox for upselling an additional option to a plan and accounts for a recurring plan (fixes code snippet in https://www.paidmembershipspro.com/multiple-membership-levels-per-user-pmpro-workarounds/ )
<?php
function my_pmpro_adjustable_level_cost($level) {
$extra_fee = 0; // Default extra fee value
if(isset($_REQUEST['field_name'])) {
//specify the cost of the selected option
$extra_fee = 100;
// Check if the level has a recurring subscription
if (pmpro_isLevelRecurring($level)) {
@indigetal
indigetal / my_pmpro_adjustable_level_cost_v1.3.php
Last active August 4, 2023 16:21
For Paid Memberships Pro - Adjusts the cost of a level at checkout based on the selection of a custom user field checkbox for upselling an additional option to a plan. Accounts for both recurring plans and adjust the fee based on if it's a monthly or an annual plan (fixes and expands on the code snippet at https://www.paidmembershipspro.com/mult…
<?php
function my_pmpro_adjustable_level_cost($level) {
$monthly_levels = array(1, 2); // specify monthly level IDs here
$annual_levels = array(3, 4); // specify annual level IDs here
$extra_fee = 0;
if (in_array($level->id, $monthly_levels)) {
$extra_fee = 10; //specify the cost of the selected option for monthly plans
}
@indigetal
indigetal / pmpro-spacesengine.php
Last active May 14, 2024 00:32
WORK IN PROGRESS: Monetize SpacesEngine using Paid Memberships Pro and Selection of Addons. See link to accompanying tutorial in comments.
<?php
/*
Plugin Name: Paid Memberships Pro Integration with SpacesEngine for BuddyBoss
Plugin URI: https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
Description: Integrate Paid Memberships Pro With SpacesEngine for BuddyBoss
Version: 0.2.6
Author: Brandon Meyer
Author URI: indigetal.com
*/
@indigetal
indigetal / add_custom_settings_tab.php
Last active August 12, 2023 17:50
Add a custom settings tab to the user account page in BuddyBoss. Place code in theme child's functions.php file
<?php
function my_custom_user_settings_tab() {
// create the Custom Tab in the settings navigation
bp_core_new_subnav_item(
array(
'name' => __( 'Custom Tab', 'buddyboss-theme' ), // Replace 'Custom Tab' with the name of your tab
'slug' => 'custom-tab', // Change this to your desired slug
'parent_url' => bp_loggedin_user_domain() . 'settings/',
'parent_slug' => 'settings',
'screen_function' => 'add_custom_user_settings_tab',
@indigetal
indigetal / bp_subset.js
Last active November 14, 2023 19:43
Example node.js scripts to modify a SQL dump file imported from a WordPress single site and multisite installation to only retain the first 10 records from the wp_posts and wp_users tables
// Export BuddyPress-related tables for the first 10 users of the main site (subdirectory 1)
const exportMainSiteBPCommand = `
mysqldump -u ${dbConfig.user} -p${dbConfig.password} -h ${dbConfig.host} ${dbConfig.database} wp_1_bp_follow wp_1_bp_friends wp_1_bp_document wp_1_bp_document_folder wp_1_bp_document_folder_meta wp_1_bp_groups wp_1_bp_groups_groupmeta wp_1_bp_groups_membermeta wp_1_bp_groups_members wp_1_bp_invitations wp_1_bp_invitations_invitemeta wp_1_bp_messages_messages wp_1_bp_messages_meta wp_1_bp_messages_notices wp_1_bp_messages_recipients --where="user_id IN (SELECT ID FROM wp_1_users LIMIT 10)"
> db-export-main-site-bp.sql
`;
// Export BuddyPress-related tables for the first 10 users of the second site (subdirectory 2)
const exportSecondSiteBPCommand = `
mysqldump -u ${dbConfig.user} -p${dbConfig.password} -h ${dbConfig.host} ${dbConfig.database} wp_2_bp_follow wp_2_bp_friends wp_2_bp_document wp_2_bp_document_folder wp_2_bp_document_folder_meta wp_2_bp_groups wp_2_bp_groups_groupme
@indigetal
indigetal / content-blocks-controls.php
Last active February 14, 2024 17:13
Add filter's to Content Block's of the Blocksy Theme
<?php
/**
* This snippet allows custom filtering based on a content block's ID.
*
* To use, create a content-blocks-controls.php file in the child theme and add the followng line to the functions.php file:
* require_once get_stylesheet_directory() . '/content-blocks-controls.php';
*/
// Add a filter to modify the condition match for Blocksy Pro content blocks
add_filter(