Skip to content

Instantly share code, notes, and snippets.

View viruthagiri's full-sized avatar

Viruthagiri Thirumavalavan viruthagiri

  • Bangalore, India
View GitHub Profile
@viruthagiri
viruthagiri / gist:1761114
Created February 7, 2012 18:27 — forked from trepmal/gist:1518263
WordPress: [concept] Protect users in one role from users in another
<?php
//Plugin Name: [concept] Protect users in one role from users in another
//Description: Users in custom faux-admin role 'site administrator' cannot modify default admins
add_filter( 'map_meta_cap', 'prevent_edit_of_primary_user', 10, 4 );
function prevent_edit_of_primary_user( $caps, $cap, $user_id, $args ) {
if ( ! is_user_logged_in() ) return $caps;
@viruthagiri
viruthagiri / gist:1761116
Created February 7, 2012 18:27 — forked from trepmal/gist:1557750
WordPress: Network-Wide Tips
<?php
/*
Plugin Name: Network-Wide Tips
Description: Save multiple notices, only activate one at a time. Displayed across WP Network.
Author: Kailey Lampert
Author: http://kaileylampert.com
Version: 1.0
*/
@viruthagiri
viruthagiri / multisite_functions.php
Created February 7, 2012 18:28 — forked from freekrai/multisite_functions.php
Some handy wordpress multisite functions
<?php
$posts = multisite_latest_post( array(
"how_many"=>10,
"how_long_days"=>30,
"how_many_words"=>50,
"more_text"=>"[...]",
"remove_html"=>true,
"sort_by"=>"post_date",
// if paginating:
"paginate"=>true,
@viruthagiri
viruthagiri / gist:1761124
Created February 7, 2012 18:29 — forked from freekrai/gist:1149844
wordpress redirect on login based on roles
function fs_login($user, $pass) {
$uname = $user;
$pass1 = $pass;
$credentials = array(
'user_login' => $user,
'user_password' => $pass,
'remember' => true
);
$user = wp_signon($credentials, false);
if( $user->ID ){
@viruthagiri
viruthagiri / filter_wpmu_signup_user_notification.php
Created February 7, 2012 18:29
Change the default WordPress MultiSite user notification mail from using the main network admin_email and site_name to the blog admin_email & blogname.
<?php
add_filter( 'wpmu_signup_user_notification', 'dk_wpmu_signup_user_notification', 10, 4 );
/**
* Problem: WordPress MultiSite sends user signup mails from the main site. This is a problem when using domain mapping functionality as the sender is not the same domain as expected when creating a new user from a blog with another domain.
* Solution: Change the default user notification mail from using the main network admin_email and site_name to the blog admin_email & blogname
*
* @author Daan Kortenbach
* @link http://daankortenbach.nl/wordpress/filter-wpmu_signup_user_notification/
*/
function dk_wpmu_signup_user_notification($user, $user_email, $key, $meta = '') {
@viruthagiri
viruthagiri / class-gsa-for-wp-ms.php
Created February 7, 2012 18:31 — forked from simonwheatley/class-gsa-for-wp-ms.php
GSA for WordPress Multisite
<?php
/**
* Handles most of the work.
*
* @package GSA for WordPress Multisite
* @author Simon Wheatley
**/
class GSAForWPMS extends GSAForWPMS_Plugin {
@viruthagiri
viruthagiri / wordpress-multisite-lighttpd.conf
Created February 7, 2012 18:31 — forked from ahmednuaman/wordpress-multisite-lighttpd.conf
A nice little rewrite directive for WordPress Multi-site and Lighttpd
url.rewrite-once = (
"^/(.*/)?files/$" => "/index.php",
"^/(.*/)?files/(.*)" => "/wp-content/blogs.php?file=$2",
"^(/wp-admin/.*)" => "$1",
"^/([_0-9a-zA-Z-]+/)?(wp-.*)" => "/$2",
"^/([_0-9a-zA-Z-]+/)?(.*\.php)" => "/$2",
"^/(.*)/?$" => "/index.php"
)
@viruthagiri
viruthagiri / tc.framwork.base.php
Created February 7, 2012 18:35 — forked from amereservant/tc.framwork.base.php
WordPress Options Framework
<?php
/**
* TC Framework Base
*
* This is an abstract class that creates a standard base for all TC projects.
*
* All options are stored under two WordPress options, one for the standard options
* and another for the multisite options (if the theme/plugin has need for these).
*
* @author Amereservant <amereservant@gmail.com>
@viruthagiri
viruthagiri / functions.php
Created February 15, 2012 18:29
Editing WordPress profiles with Gravity Forms
<?php
// add the following to your functions file or similar
define( 'FUBLO_GF_PROFILE', 1 ); // define the ID number of your profile form.
// ============================================================= PROFILE EDITING
/**
* These are the user metadata fields, with their names and the data about them.
@viruthagiri
viruthagiri / hidden_comment_form.php
Created February 15, 2012 18:32 — forked from beastaugh/hidden_comment_form.php
Plugin to hide the WordPress comment form until the user clicks a link to reveal it.
<?php
/*
Plugin Name: Hidden Comment Form
Plugin URI: http://tarskitheme.com/help/hooks/example-plugins/
Description: Hide the comment form until the user clicks a link to reveal it.
Author: Benedict Eastaugh
Version: 1.1
Author URI: http://extralogical.net/
*/