Plugin: Default Friend 0.1
-
I’ve developed that plugin as promised.
It add automatically a friend to new registred user,
I haven’t tried it yet but i think it works, so don’t be angry and against me if it doesn’t work, i wrote this code in 15 minutes while i was having breakfast
<?php
/*
Plugin Name: BP Default Friend
Description: Automatically add a specified user as friend after SignUp
Plugin URI: http://notsecurity.com/default-friend
Author: Nicola Greco
Author URI: http://notsecurity.com
Version: 0.1
*/
function default_friend() {
global $wpdb, $bp;
$wpdb->query("INSERT INTO " . $bp['friends']['table_name'] . " ( initiator_user_id, friend_user_id, is_confirmed, is_limited, date_created ) VALUES (".bp_current_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, 'default-friend', 'default_friend_options');
}
function default_friend_options() {
if(isset($_POST['submitted'])) {
$default_friend_id = $_POST['bp-default-friend-id'];
update_option( 'bp-default-friend-id', $default_friend_id );
echo "<div id="message" class="updated fade"><strong>Options updated.</strong>
</div>";
}
?>
<div class="wrap">
<h2><?php _e( 'Default Friend', 'buddypress' ) ?></h2>
<form action="<?php $_SERVER['PHP_SELF'] ?>" 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' );
add_action('admin_menu', 'default_friend_control');
?>Install this plug in in /wp-content/mu-plugins and activate it, then in the Site Admin Menu will appear a new voice “Default Friend”, and write there the id of the default friend
I post that code quickly because i think community will do better
Viewing 17 replies - 1 through 17 (of 17 total)
Viewing 17 replies - 1 through 17 (of 17 total)
- The topic ‘Plugin: Default Friend 0.1’ is closed to new replies.