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 / Hide events that are associated to a BP group.php
Last active August 29, 2015 14:10
Hide WPMU events that are associated to a BP group
<?php
function custom_posts_events( $query ){
if( ! is_admin() && ! is_super_admin() ){
if( is_archive() ){
$grps = BP_Groups_Member::get_group_ids( get_current_user_id() );
$marr['relation'] = 'OR';
$marr[] = array(
'key' => 'eab_event-bp-group_event',
@bappi-d-great
bappi-d-great / init.php
Created December 3, 2014 17:37
Support Custom Taxonomy Name translation with qTranslate plugin
<?php
function qtranslate_edit_taxonomies(){
$args=array(
'public' => true ,
'_builtin' => false
);
$output = 'object'; // or objects
$operator = 'and'; // 'and' or 'or'
@bappi-d-great
bappi-d-great / Enable a theme in all subsites.php
Created December 3, 2014 17:59
Enable a theme in all subsites
<?php
// RUN IT ONCE ONLY and USE as mu-plugin
/*
* To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'.
* If there is no folder in that name, then create a folder, name it 'mu-plugins',
* create a file inside that, give any name you like and paste the code in there.
* You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always.
* If you use mu-plugins then add a php start tag at the beginning of the code.
@bappi-d-great
bappi-d-great / code.php
Created December 10, 2014 16:25
Sorting membership in register page for protected content
<?php
add_filter( 'ms_model_membership_get_signup_membership_list', 'ms_model_membership_get_memberships_cb', 99, 3 );
function ms_model_membership_get_memberships_cb( $memberships, $exclude_ids, $only_names ) {
// This is IMPORTANT. You have to put all child memberships ID in here in the order you want to show.
$new_order = array( 262, 266, 263 );
$new_membership = array();
foreach( $memberships as $membership ){
@bappi-d-great
bappi-d-great / Show all available themes in a network with screenshot.php
Created December 13, 2014 21:48
Show all available themes in a network with screenshot
<?php
/*
* Use: [show_available_themes] or [show_available_themes col="3"]
*/
function show_available_themes_cb( $atts ) {
$atts = shortcode_atts( array(
'col' => 4
), $atts, 'show_available_themes' );
$themes = wp_get_themes();
@bappi-d-great
bappi-d-great / How to use custom post type archive as front page.php
Last active July 30, 2019 22:49
How to use custom post type archive as front page
<?php
/*
* 1. Go to Settings > Permalinks and select any page as home page
* Then use the following code
*
* You can add those codes in your functions.php in the theme, if you think your theme won’t be changed.
* Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'.
* If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that,
* give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins,
* so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.
@bappi-d-great
bappi-d-great / Force to have same display name as username in wordpress.php
Created December 21, 2014 19:32
Force to have same display name as username in wordpress
<?php
add_action('init', 'change_display_name' );
add_action( 'profile_update', 'change_display_name' );
function change_display_name() {
$users = get_users();
foreach( $users as $user ){
if( $user->user_login != $user->display_name ){
wp_update_user( array ('ID' => $user->ID, 'display_name'=> $user->user_login) ) ;
}
@bappi-d-great
bappi-d-great / How to create different thumb size for different post type.php
Last active November 18, 2017 23:45
How to create different thumb size for different post type
<?php
add_action( 'pre-upload-ui', 'get_the_post_type' );
function get_the_post_type() {
$post_type = isset( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : 'post';
set_transient( 'attached_post_type', $post_type );
}
add_filter( 'intermediate_image_sizes_advanced', 'add_image_size_for_post_type', 10 );
function add_image_size_for_post_type( $sizes ) {
@bappi-d-great
bappi-d-great / Add more currency in WPMU membership plugin.php
Last active April 10, 2018 17:19
Add more currency in WPMU membership plugin
<?php
add_filter( 'ms_model_settings_get_currencies', 'membership_available_currencies_cb' );
function membership_available_currencies_cb( $arr ){
$arr['SYMBOL'] = 'SYMBOL - YOUR CURRENCY NAME';
return $arr;
}
@bappi-d-great
bappi-d-great / Auto enroll to courses when an member is registered.php
Created January 2, 2015 15:08
Auto enroll to courses when an member is registered
<?php
add_action( 'user_register', 'user_register_cb', 10, 1 );
function user_register_cb( $user_id ){
//You need to provide the course IDs in the following array
$courses = array( 102, 322, 424 );
$student = new Student( $user_id );
foreach( $courses as $course ){
$student->enroll_in_course( $course );
}