Wednesday, 7 May 2014

Tuesday, 6 May 2014

Manually activating a user in Buddypress

To completely activate an imported user in Buddypress, you need to update two different tables:

In wp_usermeta add a date to the last_activity field.
In wp_bp_activity add a record for each user like so
INSERT INTO `wp_new`.`wp_bp_activity` (`id`, `user_id`, `component`, `type`, `action`, `content`, `primary_link`, `item_id`, `secondary_item_id`, `date_recorded`, `hide_sitewide`, `mptt_left`, `mptt_right`, `is_spam`) VALUES (NULL, '4', 'members', 'last_activity', '', '', '', '0', NULL, '2014-05-06 12:41:51', '0', '0', '0', '0');

Only after this will the person's name be available for private messaging.

Friday, 4 April 2014

Fuzzy matching in MySql (Levenshtien Distance)

http://stackoverflow.com/questions/4671378/levenshtein-mysql-php

Friday, 31 January 2014

How to make Wordpress root-relative

Add the following lines to your wp-config file (found in the root).


define('WP_HOME',"http://" . $_SERVER['HTTP_HOST']);
define('WP_SITEURL',"http://" . $_SERVER['HTTP_HOST']);

define( 'WP_CONTENT_DIR',  dirname( __FILE__ ) . '/wp-content' );
define( 'WP_CONTENT_URL',  'http://' . $_SERVER['HTTP_HOST'] . '/wp-content' );
//  added by chetan Custom plugin directory
define( 'WP_PLUGIN_DIR',   dirname( __FILE__ ) . '/wp-content/plugins' );
define( 'WP_PLUGIN_URL',   'http://' . $_SERVER['HTTP_HOST'] . '/wp-content/plugins' );

Then prevent the functions get_site_url() and  get_home_url from accessing the wp_options database table to get the server domain or ip.

For this edit the link-template.php file:

Find the function get_home_url and comment every occurrence of this line like so:
//        $url = get_option( 'home' );

and add this:

    $url = "http://" . $_SERVER['HTTP_HOST'];

Do the same for get_site_url():

//        $url = get_option( 'siteurl' );

and add this:

    $url = "http://" . $_SERVER['HTTP_HOST'];


Now, to make sure any media files that are uploaded use root relative urls, install the following plugin:

http://wordpress.org/plugins/root-relative-urls/


Monday, 27 January 2014

VirtualBox Disable Time Sync

vboxmanage setextradata [VMname] "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" "1"

Turn it back on:
vboxmanage setextradata [VMname] "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" "0"

Tuesday, 10 December 2013

Buddypress show date and time of post instead of elapsed days and hours

In the themes functions.php add this (the 19800 is 5:30 hours in seconds for IST) :

function format_activity_date() 
{
    $activityDate=bp_get_activity_date_recorded();
    return date("M j, Y G:i", strtotime($activityDate)+19800);
}
add_filter('bp_activity_time_since', 'format_activity_date');


Note: This does not affect comments

Friday, 6 December 2013

Wordpress - Create a plugin to override a pluggable function

http://sltaylor.co.uk/blog/customizing-new-user-email-pluggable-function/

http://codex.wordpress.org/Pluggable_Functions