Skip to content

Instantly share code, notes, and snippets.

View bappi-d-great's full-sized avatar

Bappi D great bappi-d-great

View GitHub Profile
@bappi-d-great
bappi-d-great / code.php
Created May 13, 2015 21:02
WPMU Events+ show all recurring events for an event
<?php
/*
* Usage: [eab_recurring id="XXXX"]
*/
function eab_recurring_cb( $args ) {
$args = shortcode_atts( array(
'id' => false,
'slug' => false,
@bappi-d-great
bappi-d-great / code.php
Created May 15, 2015 18:15
Recurring event shortcode and show in calendar
<?php
<?php
/*
Plugin Name: Recurring Event in Calendar ShortCode
Description: Use [eab_calendar_recurring id="xx"] to show all instances of a recurring event
Plugin URI: http://premium.wpmudev.org/project/events-and-booking
Version: 1.0
Author: WPMU DEV
AddonType: Events
@bappi-d-great
bappi-d-great / code.php
Created June 1, 2015 23:09
Modified course_list shortcode to enable pagination in coursepress
<?php
function course_list( $atts ) {
extract( shortcode_atts( array(
'course_id' => '',
'status' => 'publish',
'instructor' => '', // Note, one or the other
'instructor_msg' => __( 'The Instructor does not have any courses assigned yet.', 'cp' ),
'student' => '', // If both student and instructor is specified only student will be used
@bappi-d-great
bappi-d-great / code.php
Created June 23, 2015 20:41
Hide non-pro subsites from BP Sites List - WPMU Pro Sites
<?php
add_filter( 'bp_blogs_get_blogs', 'bp_blogs_get_blogs_cb', 99, 2 );
function bp_blogs_get_blogs_cb( $blogs, $r ) {
foreach( $blogs['blogs'] as $key => $blog ){
if( ! is_pro_site( $blog->blog_id ) ) {
unset( $blogs['blogs'][$key] );
$blogs['total']--;
}
@bappi-d-great
bappi-d-great / code.php
Created July 7, 2015 18:50
Assign membership on registration in membership 2 pro
<?php
add_action( 'user_register', 'assign_membership_on_register', 10, 1 );
function assign_membership_on_register( $user_id ) {
$membership_id = 1343;
$member = MS_Factory::load( 'MS_Model_Member', $user_id );
$subscription = $member->add_membership( $membership_id );
if ( $member->has_membership() ) {
@bappi-d-great
bappi-d-great / code.php
Created July 7, 2015 19:57
Add pagination in course_list shortcode in WPMU coursepress
<?php
/**
* Usage: [course_list limit="5" pagination="true"]
*/
function edit_coursepress_shortcode(){
remove_shortcode( 'course_list');
add_shortcode( 'course_list', 'course_list_cb');
}
@bappi-d-great
bappi-d-great / code.php
Created July 8, 2015 18:58
Add additional field in join single event page
<?php
add_filter( 'wp_footer', 'wp_footer_cb' );
function wp_footer_cb() {
?>
<style>
.eav_add_field{margin: 10px 0;}
#eab_booking_form .eav_add_field{display: none}
</style>
<script type="text/javascript">
@bappi-d-great
bappi-d-great / code.php
Created July 9, 2015 09:18
Auto add member based on user email domain to a BP group and a Membership on registration
<?php
add_action( 'user_register', 'assign_membership_on_register', 10, 1 );
function assign_membership_on_register( $user_id ){
$user_info = get_userdata( $user_id );
$email = $user_info->user_email;
// Here school1, school2 are the email domains, ms_id is membership id and bp_id is the group id
$data = array(
'school1' => array(
'ms_id' => 1343,
@bappi-d-great
bappi-d-great / code.php
Created July 11, 2015 00:14
Show selected price in stripe checkout form
<?php
add_action( 'wp_footer', 'show_price' );
function show_price() {
?>
<script type="text/javascript">
jQuery(function($) {
$(document).on('click', '.choose-plan-button', function() {
var price = $(this).closest('ul').find('.summary .price:visible .plan-price').text();
if($('.price_custom_label').length)
@bappi-d-great
bappi-d-great / code.php
Last active August 29, 2015 14:24
Restrict group creation based on S2Member capabilities
<?php
// Define the number of groups can be created by paid users
if( ! defined( 'PAID_USER_GROUP_LIMIT' ) ) define( 'PAID_USER_GROUP_LIMIT', 5 );
// Define the error message
if( ! defined( 'PAID_USER_GROUP_LIMIT_PROTECTION_MSG' ) ) define( 'PAID_USER_GROUP_LIMIT_PROTECTION_MSG', "Either You have exceeded the no. of groups you can create or you don't have permission to create group." );
function is_custom_free_member() {
if( is_user_logged_in() ){
if( current_user_is( 's2member_level0' ) ){