Skip to content

Instantly share code, notes, and snippets.

View indigetal's full-sized avatar

Brandon Meyer indigetal

  • Indigetal WebCraft
  • NC
View GitHub Profile
@indigetal
indigetal / add_custom_settings_tab.php
Last active March 21, 2025 20:23
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 / bb-recent-posts.json
Created February 20, 2025 18:06
(BB) Recent Post Block Pattern
{
"__file": "wp_block",
"title": "(BB) Recent Posts",
"content": "<!-- wp:greenshift-blocks/element {\"id\":\"gsbp-e27805b\",\"inlineCssStyles\":null,\"type\":\"inner\",\"localId\":\"gsbp-e27805b\",\"styleAttributes\":{\"paddingTop\":[\"1.25rem\"],\"backgroundColor\":[\"var(\\u002d\\u002dbb-content-background-color)\"],\"borderRadius\":[\"var(\\u002d\\u002dbb-block-radius)\"],\"borderWidth\":[\"1px\"],\"borderStyle\":[\"solid\"],\"borderColor\":[\"#f0f1f1\"],\"paddingBottom\":[\"1.5625rem\"],\"paddingRight\":[\"1.25rem\"],\"paddingLeft\":[\"1.25rem\"],\"borderTopLeftRadius\":[\"10px\"],\"borderRadiusLink_Extra\":true,\"borderBottomLeftRadius\":[\"10px\"],\"borderTopRightRadius\":[\"10px\"],\"borderBottomRightRadius\":[\"10px\"]},\"blockVisibility\":{\"query_by\":\"user\",\"user_logged_in\":true,\"user_roles\":[{\"label\":\"Administrator\",\"id\":\"administrator\",\"value\":\"administrator\"}]}} -->\n<div class=\"gsbp-e27805b\"><!-- wp:greenshift-blocks/element {\"id\":\"gsbp-fdfda2d\",\"inlineCssStyles\
@indigetal
indigetal / tutor-lms-course-grid.json
Last active January 13, 2025 15:56
GreenShift: Tutor LMS Course Grid Layout
{
"__file": "wp_block",
"title": "Tutor LMS Course Grid",
"content": "<!-- wp:html -->\n<style>\n/* Format course duration display */\n.course-duration {\n display: inline-flex;\n align-items: center;\n gap: 0.25em; /* Optional spacing between elements */\n}\n\n/* Add \"h\" after the hours span */\n.course-duration .gspb_meta_result_tags span:first-child::after {\n content: \"h\";\n margin-right: 0.25em;\n}\n\n/* Add \"m\" after the minutes span */\n.course-duration .gspb_meta_result_tags span:nth-child(2)::after {\n content: \"m\";\n}\n/* Hide the seconds span */\n.course-duration .gspb_meta_result_tags span:nth-child(3) {\n display: none;\n}\n\n/* Grey out the course price when it is on sale */\n.course-cost-container .tutor-course-price {\n color: inherit;\n text-decoration: none;\n}\n.course-cost-container .tutor-course-price + .tutor-sale-price,\n.course-cost-container .tutor-sale-price ~ .tutor-course-price {\n opacity: .5;\n font-weight: 400;\n text-decoration:
@indigetal
indigetal / job-listings.json
Last active December 3, 2024 00:15
Grid of Job Listings for WPJM with GreenShift
{
"__file": "wp_block",
"title": "job-listings",
"content": "<!-- wp:greenshift-blocks/querygrid {\"id\":\"gsbp-7e5a45e\",\"inlineCssStyles\":\".gspbgrid_id-gsbp-7e5a45e .wp-block-post-template {list-style:none;margin:0;padding:0} .gspbgrid_id-gsbp-7e5a45e .wp-block-post-template:before{display:none!important}.gspbgrid_id-gsbp-7e5a45e .wp-block-post-template \\u003e li {width:100%!important}.gspbgrid_id-gsbp-7e5a45e .gspb_ajax_pagination_btn{display:inline-block;cursor:pointer}.gspbgrid_id-gsbp-7e5a45e .wp-block-post-template \\u003e .gspbgrid_item:hover{box-shadow: 0 5px 23px 0 rgba(188, 207, 219, 0.35);}.gspbgrid_id-gsbp-7e5a45e .wp-block-post-template \\u003e .gspbgrid_item{overflow:hidden;}.gspbgrid_id-gsbp-7e5a45e .wp-block-post-template \\u003e .gspbgrid_item{border-top-left-radius:6px;border-top-right-radius:6px;border-bottom-right-radius:6px;border-bottom-left-radius:6px;}.gspbgrid_id-gsbp-7e5a45e .wp-block-post-template \\u003e .gspbgrid_item{border-style:solid;border-width:1px;border-color:#7
@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 / 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(
@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 / 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_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.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';