Skip to content

Instantly share code, notes, and snippets.

@sjaved87
sjaved87 / remove_notices_for_non_admins.php
Created September 19, 2015 09:48
remove notices for all users except admins
function hide_update_noticee_to_all_but_admin_users()
{
if (!current_user_can('update_core')) {
remove_all_actions( 'admin_notices' );
}
}
add_action( 'admin_head', 'hide_update_noticee_to_all_but_admin_users', 1 );
@sjaved87
sjaved87 / mp_after_order_remove_register_lightbox.php
Created November 5, 2015 18:41
This code will remove the MarketPress registration PopUp after order. Simply copy and past in functions.php file or use as mu-plugin.
<?php
if ( ! function_exists( 'remove_anonymous_object_filter' ) )
{
/**
* Remove an anonymous object filter.
*
* @param string $tag Hook name.
* @param string $class Class name
* @param string $method Method name
@sjaved87
sjaved87 / filter_attendee_by_payment_status_on_export.php
Created November 12, 2015 21:57
use this mu-plugin to add two seperate buttons for export as paid, not paid and all.
<?php
function wpmu_bookings_export_filter_by_ps($export_data, $event, $booking, $user_data){
//if export all then don't bother.
if(! isset( $_GET['paid'] ) ) return $export_data;
//check if paid event if yes then proceed other wise return.
if ($event->is_premium()) {
$payment_status = $event->user_paid($booking->user_id) ? __('Yes', Eab_EventsHub::TEXT_DOMAIN) : __('No', Eab_EventsHub::TEXT_DOMAIN);
@sjaved87
sjaved87 / gist:f434fdae300091cc3bd1
Created November 22, 2015 11:44
Membership 2 : Its a custom add-on to limit the number of blog a member can create within a membersihp. Dependent on membership attributes add-on.
<?php
/**
* Plugin Name: Membership 2 Site Limitation
* Version: 1.0
* Description: Limit number of blogs a member can create on multisite.
* Author: Sajid Javed From Incsub
* Author URI: http://premium.wpmudev.org/
*/
class MS_Custom_Addon_Sitelimit {
@sjaved87
sjaved87 / cp_course_time.php
Created November 27, 2015 18:48
CoursePress Pro - Convert time from minutes into hours.
<?php
add_filter( 'coursepress_unit_time_estimation_minutes_and_seconds_format', 'cp_convert_minutes_to_hours', 10, 2 );
function cp_convert_minutes_to_hours( $time ) {
$get_minutes = explode(":", $time);
if($get_minutes[0] < 90) return $time;
$hours = round( ( $get_minutes[0] / 60 ) , 2) ;
@sjaved87
sjaved87 / ms_subscription.php
Created December 2, 2015 12:55
Membership 2 - Display expiry date.
<?php
function wpmu_display_membership_expiry_date($atts){
$returner = '';
$args = shortcode_atts( array('user_id' => '',
'membership' => ''
), $atts);
extract($args);
@sjaved87
sjaved87 / delete_recently_active_plugins_list.php
Created February 6, 2016 12:20
This small snippet will delete recently plugins list of WordPress.
<?php
add_action('admin_init', 'wpmudev_delete_recent_plugins_list');
function wpmudev_delete_recent_plugins_list(){
delete_option('recently_activated');
}
@sjaved87
sjaved87 / cimy_feilds_in_ms_edit_form.php
Last active February 9, 2016 17:43
This mu-plugin will add cimy user extra fields in Membership 2 edit profile form on frontend. Use it as mu-plugin or copy paste the code in fucntions.php file
<?php
function wpmu_add_cimy_extra_fileds_in_edit_form($feilds, $object){
$user_ID = get_current_user_id();
$user_meta_values = get_cimyFieldValue($user_ID, false);
if($user_meta_values){
//Unset now, we will add those later, at the end :)
unset($feilds['submit'], $feilds['_wpnonce'], $feilds['action']);
@sjaved87
sjaved87 / disablepluginpersite.php
Last active February 10, 2016 13:57
disable a network enabled plugin for just one or more subsite(s)
<?php
/*
This simple snippet willy disable plugin per site basis.
Replace 2,3,4 with acutal website ID(s) for those you want to disable this plugin
This snippet can also be used to disable any network activated plugin. Only thing you have to do is copy the folder and file name of plugin e.g akismet/akismet.php
*/
add_filter('site_option_active_sitewide_plugins', 'wpmu_modify_sitewide_plugins');
function wpmu_modify_sitewide_plugins($value) {
global $current_blog;
@sjaved87
sjaved87 / gist:b5bc6053e04be0fbe729
Created May 28, 2015 08:34
Remove tinyMCE buttons based on role
if( !function_exists('wpmu_hide_itmes') ):
function wpmu_hide_itmes($buttons)
{
//do not remoe any button if its super admin or pro users
if(current_user_can('pro') or is_super_admin() ) return $buttons;
//Remove the text color selector
$remove = array( 'msp_shortcodes_button', 'wsalestoolbox_tc_button', 'icon' );