Re: Plugin: Default Friend 0.1
<?php
/*
Plugin Name: BP Default Friend
Author: DJPaul
Author URI: djpaul@gmail.com
Original Author: Nicola Greco
Original Author URI: http://notsecurity.com
Description: Automatically add a specified user as friend after SignUp
Plugin URI: http://djpaul.dangerous-minds.org
Version: 0.2
*/
require_once(WP_CONTENT_DIR . '/mu-plugins/bp-core.php');
function default_friend($user_id) {
global $wpdb, $bp;
$wpdb->query("INSERT INTO " . $bp . " ( initiator_user_id, friend_user_id, is_confirmed, is_limited, date_created ) VALUES (".$user_id.", ".get_option('bp-default-friend-id').", 1, 0, NOW())");
}
function default_friend_control() {
add_submenu_page("wpmu-admin.php", 'Default Friend', 'Default Friend', 8, 'bp-default-friend', 'default_friend_options');
}
function default_friend_options() {
if(isset($_POST)) {
$default_friend_id = $_POST;
update_option( 'bp-default-friend-id', $default_friend_id );
echo "<div id="message" class="updated fade">Options updated.</div>";
}
?>
<div class="wrap">
<h2><?php _e( 'Default Friend', 'buddypress' ) ?></h2>
<form action="<?php $_SERVER ?>" method="post" id="options">
<table class="form-table">
<tbody>
<tr>
<th scope="row">Default Friend ID:</th>
<td><input name="bp-default-friend-id" id="bp-default-friend-id" value="<?php echo get_option('bp-default-friend-id') ?>" />
</td>
</tr>
</tbody>
</table>
<p class="submit">
<input name="submitted" type="hidden" value="yes" />
<input type="submit" name="bp-default-friend" id="bp-default-friend" value="<?php _e( 'Save Settings', 'buddypress' ) ?>"/>
<?php wp_nonce_field( 'bp-default-friend') ?>
</form>
</div>
<?php
}
add_action('wpmu_activate_user', 'default_friend', 1, 1);
add_action('admin_menu', 'default_friend_control');
?>