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 buddypress profile groups for WPMU membership (FREE version) Level.php
Created August 2, 2014 18:36
Hide buddypress profile groups for WPMU membership (FREE version) Level
<?php
/*
* $restricted_level is the level ID that needs to be restricted to see BP profile fields
* .bp-widget.contact-details here .contact-details should be the class name of the profile group
*/
add_action( 'wp_head', 'hide_bp_field' );
function hide_bp_field() {
if( is_user_logged_in() ){
$restricted_level = 1;
$current_user = wp_get_current_user();
@bappi-d-great
bappi-d-great / Get wordpress subsite information in network interface.php
Created August 8, 2014 10:31
Get wordpress subsite information in network interface
<?php
/*
Plugin Name: Site Info
Plugin URI: http://premium.wpmudev.org/
Description: Will shows information about all subsites
Version: 1.0.1
Author: Ashok (Incsub)
Author URI: http://bappi-d-great.com
License: GNU General Public License (Version 2 - GPLv2)
Network: true
@bappi-d-great
bappi-d-great / code.php
Created August 18, 2014 10:04
Stop redirecting to WP login page from WPMU membership widget
<?php
add_action( 'wp_login_failed', 'my_front_end_login_fail' );
function my_front_end_login_fail( $username ) {
$referrer = $_SERVER['HTTP_REFERER'];
$findme = '?login=failed';
$pos = strpos( $referrer, $findme );
if ( !empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin') ) {
if( $pos === false ) {
@bappi-d-great
bappi-d-great / code.php
Created August 20, 2014 10:10
Show category description in WPMU classified listing
<?php
function the_dr_categories_home_theme( $echo = true, $atts = null ){
extract( shortcode_atts( array(
'style' => '', //list, grid
'lcats' => '', //
), $atts ) );
//get plugin options
@bappi-d-great
bappi-d-great / code.php
Created August 22, 2014 23:29
WPMU Custom Sidebar - different sidebar in different BP group
<?php
add_action('wp', 'set_sidebar', 10);
function set_sidebar() {
global $_wp_sidebars_widgets, $bp;
switch( $bp->groups->current_group->id ) {
case 1:
$_wp_sidebars_widgets['REPLACEABLE SIDEBAR ID'] = $_wp_sidebars_widgets['REPLACED SIDEBAR ID'];
break;
case 2:
@bappi-d-great
bappi-d-great / allow one appointment per day.php
Created August 29, 2014 18:35
WPMU A+ allow one appointment per day
<?php
// Works only if login required
function limit_active_apps( $reply_array ) {
global $wpdb, $current_user, $appointments;
// Change statuses as required. i.e. remove pending condition if you wish
$count = $wpdb->get_var( "SELECT COUNT(*) FROM " . $appointments->app_table . " WHERE user=".$current_user->ID." AND (status='pending' OR status='confirmed' OR status='paid' ) and created > DATE_SUB(CURDATE(), INTERVAL 1 DAY)" );
if ( $count >= 3)
return array( 'error'=>'You have reached maximum allowed number of appointments' );
return $reply_array;
}
@bappi-d-great
bappi-d-great / Load service providers via ajax.php
Last active August 29, 2015 14:06
Load service providers via ajax in WPMU Appointments
<?php
add_action( 'wp_footer', 'ajax_app_auto_load' );
function ajax_app_auto_load() {
?>
<style>
.app_services_button{display: none;}
</style>
<script type="text/javascript">
jQuery(function($){
@bappi-d-great
bappi-d-great / How to load a wordpress plugin at very last.php
Created September 6, 2014 14:47
How to load a wordpress plugin at very last - change plugin order to load last
<?php
/*
*
* Use the code at the beginning of a plugin that you want to be laoded at last
*
*/
function this_plugin_last() {
$wp_path_to_this_file = preg_replace('/(.*)plugins\/(.*)$/', WP_PLUGIN_DIR."/$2", __FILE__);
$this_plugin = plugin_basename(trim($wp_path_to_this_file));
$active_plugins = get_option('active_plugins');
@bappi-d-great
bappi-d-great / Add all users in a buddypress group.php
Created September 9, 2014 13:41
Add all users in a buddypress group
<?php
/*
* Needs php greatet than 5.3
*
* (not for all, written for special purpose)
*/
add_action('load-users.php',function() {
if(isset($_GET['action']) && isset($_GET['bp_gid']) && isset($_GET['users'])) {
@bappi-d-great
bappi-d-great / How to write dynamic css in a php file in wordpress.php
Last active December 19, 2024 18:37
How to write dynamic css in a php file in wordpress
<!-- functions.php -->
<?php
add_action( 'wp_enqueue_scripts', 'theme_custom_style_script', 11 );
function theme_custom_style_script() {
wp_enqueue_style( 'dynamic-css', admin_url('admin-ajax.php').'?action=dynamic_css', '', VERSION);
}
add_action('wp_ajax_dynamic_css', 'dynamic_css');
add_action('wp_ajax_nopriv_dynamic_css', 'dynamic_css');