Skip to content

Instantly share code, notes, and snippets.

View greathmaster's full-sized avatar
🧐

Hersha Venkatesh greathmaster

🧐
  • San Francisco, Bay Area
View GitHub Profile
@greathmaster
greathmaster / pmpro-member-number-csv.php
Last active September 21, 2022 12:37
Show member number in Members List and Members List CSV export.
//Show member number in Members List and Members List CSV export
//Requires PMPro Member Number Gist:
//https://gist.github.com/strangerstudios/3d2824b8caf56734a54a#file-generate_member_number-php
function my_pmpro_members_list_csv_extra_columns($columns)
{
$columns["member_number"] = "my_extra_column_member_number";
return $columns;
}
@greathmaster
greathmaster / pmpro-bbpress-addon-package-integration.php
Last active June 21, 2022 21:30
Glue code for PMPro Add On Packages and PMPro bbPress. Allows you to sell access to individual forums by using the PMPro Add On Packages
/*
Glue code for PMPro Add On Packages and PMPro bbPress. Allows you to sell access to individual forums by using the PMPro Add On Packages
*/
function my_pmproap_supported_post_types($post_types)
{
$post_types[] = 'forum';
return $post_types;
}
@greathmaster
greathmaster / add-to-buddypress-groups-based-on-xprofile-selection-upon-activation.php
Last active December 10, 2021 17:13
Add to BuddyPress groups and bbPress forum subscription based on xProfile checkbox selection
/*
Add to BuddyPress groups and forums (including sub-forums) based on xProfile checkbox selection
*/
function my_bp_core_signup_user($user_id)
{
$groups = array(1 => "HIKING",
2 => "PADDLING",
3 => "CYCLING",
4=> "SKIING",);
@greathmaster
greathmaster / pmpro-format-phone-number.php
Created October 26, 2016 07:36
Actively formats phone number into XXX-XXX-XXXX format
//Actively formats phone number into XXX-XXX-XXXX format
function format_phone_number()
{
//Adapted from: http://stackoverflow.com/questions/26412623/jquery-or-javascript-to-autoformat-phone-mask
echo
"<script>
<!--
jQuery('#bphone').keyup(function(ev) {
var key = ev.which;
@greathmaster
greathmaster / force-top-discount-code-field-to-always-open.php
Created July 29, 2016 17:25
Register Helper code to force top discount code field to be visible
function my_pmprorh_init()
{
//don't break if Register Helper is not loaded
if(!function_exists("pmprorh_add_registration_field"))
{
return false;
}
//define the fields
$fields = array();
$fields[] = new PMProRH_Field(" ", "html", array("html"=>
@greathmaster
greathmaster / directory.php
Created June 22, 2017 00:05
Meta Key and Meta Value restrictions for PMPRo Member Directory that supports restriction by meta_key and meta_value. Example Usage [pmpro_member_directory meta_key = 'company' meta_value = 'ACME']
<?php
/*
This shortcode will display the members list and additional content based on the defined attributes.
*/
function pmpromd_shortcode($atts, $content=null, $code="")
{
// $atts ::= array of attributes
// $content ::= text within enclosing form of shortcode element
// $code ::= the shortcode found, when == callback name
// examples: [pmpro_member_directory show_avatar="false" show_email="false" levels="1,2"]
@greathmaster
greathmaster / pmpro-group-discount-order-csv-export.php
Created April 14, 2017 02:56
Add the group code column to the Order CSV export
<?php
//Add the group code column to the Order CSV export
//Set up the column header and callback function
function my_pmpro_orders_csv_extra_columns($columns)
{
$columns["group_code"] = "my_extra_order_column_notes";
return $columns;
}
@greathmaster
greathmaster / pmpro-invite-only-example.php
Created March 7, 2016 22:16
PMPro Invite Only Example Setup
//declare as globals
global $pmproio_invite_required_levels;
global $pmproio_invite_given_levels;
$pmproio_invite_required_levels = array(4);
$pmproio_invite_given_levels = array(5);
define('PMPROIO_CODES',0);
define('PMPROIO_CODES_USES',1);
@greathmaster
greathmaster / pmpro-lock-membership-levels-lock-all-existing-members.php
Created December 15, 2018 00:05
PMPro Lock Membership Levels-lock existing members. Add this to your customizations plugin and refresh the page. Recommend deleting the code snippet after the operation is complete.
/*
PMPro Lock Membership Levels-lock existing members. Add this to your customizations plugin and refresh the page. Recommend deleting the code snippet after the operation is complete.
*/
function bulk_lock_all_members()
{
global $wpdb;
$users = $wpdb->get_results( "SELECT ID FROM $wpdb->users" );
if( $users ) {
foreach ( $users as $user ) {
update_user_meta( $user->ID, 'pmprolml', 1 );
/*
Remove "Membership Level" on the BuddyPress profile page, and instead only show the membership level name
*/
function my_pmpro_bp_show_level_on_bp_profile() {
if ( !function_exists('pmpro_getMembershipLevelForUser') ) {
return;
}