[buddypress-dev] About me widget
Andreas Hanfelt
andreas at hanfelt.se
Mon Jun 30 20:13:12 GMT 2008
I also hacked about me widget from xiando to work with buddypress its
not some nice hack but it works for me ...
paste in a file aboutme.php and put it in mu-plugins
<?php
/*
Plugin Name: Simple About Me widget
Plugin URI: http://livelyblog.com/
Description: Adds a very simple "About Me" widget to your sidebar
which uses the profile
Author: xiando
Version: 0.1
Author URI: http://torrentchannel.com/
*/
function widget_aboutme_init() {
if ( !function_exists('register_sidebar_widget') || !
function_exists('register_widget_control') )
return;
function widget_aboutme_control() {
$options = $newoptions = get_option('widget_aboutme');
if ( !is_array($newoptions) )
$newoptions = array(
'title' => 'About Me',
'showpic' => 'on',
'longdesc' => 'on',
'alignpic' => 'left',
);
if ( $_POST['aboutme-submit'] ) {
$newoptions['title'] =
strip_tags(stripslashes($_POST['aboutme-title']));
$newoptions['showpic'] =
$_POST['aboutme-showpic'];
$newoptions['alignpic'] =
$_POST['aboutme-alignpic'];
$newoptions['longdesc'] =
$_POST['aboutme-longdesc'];
}
if ( $options != $newoptions ) {
$options = $newoptions;
update_option('widget_aboutme',
$options);
}
$title = htmlspecialchars($options['title'],
ENT_QUOTES);
echo "<ul style=\"margin-left:0px;padding-left:0px;\"><li style=
\"list-style: none;\"><label for=\"aboutme-title\"><strong>About Me</
strong></label></li>";
echo '<li style="list-style: none;">';
echo '<label>Vis profilbilde?:</label>';
echo '<input type="checkbox" name="aboutme-showpic" id="aboutme-
showpic"';
if ($options['showpic'] == "on") {
echo ' checked="checked" ';
}
echo '/></li>';
echo '<li style="list-style: none;">Align profile picture';
echo '<label for="alignpic-left"><input type="radio" name="aboutme-
alignpic" id="alignpic-left" value="left" ';
if ($options['alignpic'] == "left") {echo ' checked="checked" ';}
echo '/> Left </label>';
echo '<label for="alignpic-center"><input type="radio" name="aboutme-
alignpic" id="alignpic-center" value="center" ';
if ($options['alignpic'] == "center") {echo ' checked="checked" ';}
echo '/> Center </label>';
echo '<label for="alignpic-right"><input type="radio" name="aboutme-
alignpic" id="alignpic-right" value="right" ';
if ($options['alignpic'] == "right") {echo ' checked="checked" ';}
echo '/> Right </label>';
echo '</li>';
echo '<li style="list-style: none;">
<label for="aboutme-title">Tittel:
<input style="width: 50%;" id="aboutme-title"
name="aboutme-title" type="text" value="'.$title.'" />
</label></li>';
echo '<li style="list-style: none;">
<label>Show "About Me" text?:</label>
<input type="checkbox" name="aboutme-longdesc" id="aboutme-longdesc"';
if ($options['longdesc'] == "on") { echo 'checked="checked"'; }
echo ' /></li>';
echo '</ul><input type="hidden" id="aboutme-submit"
name="aboutme-submit" value="1" />';
}
function widget_aboutme($args) {
global $wpdb, $blog_id, $wpmuBaseTablePrefix;
extract($args);
$options = get_option('widget_aboutme');
$title = $options['title'];
$showpic = $options['showpic'];
$longdesc = $options['longdesc'];
$blogownerid = $wpdb->get_var("SELECT post_author FROM " .
$wpmuBaseTablePrefix . $blog_id . "_posts");
$userdata = get_userdata($blogownerid);
$author_gravatar = ' ';
if ($showpic == "on") {
?><?php
//$sida = get_option('siteurl');
//$olika = md5(rand());
//$test = '<img src='. $sida .'/avatar/128.png?ver='. $olika .'/>';
//echo ($blogownerid);
$bp_profile_pix = xprofile_get_avatar($blogownerid, $version = 2);
// echo $bp_profile_pix;
$author_gravatar = '<li><div style="text-align:' .
$options['alignpic'] . ';">'
. $test . '</div></li>';
?><?php
if (function_exists('author_gravatar_tag') &&
profile_picture_set($blogownerid)) {
$author_gravatar = '<li><div style="text-align:' .
$options['alignpic'] . ';">'
. author_gravatar_tag($blogownerid,"class='profilepic'") .
$bp_profile_pix . '</div></li>';
}
}
if ($longdesc == "on") {
$aboutmeauthordesc = $userdata->description;
}else{
$aboutmeauthordesc = ' ';
}
echo $before_widget . $before_title . $title . $after_title;
echo '<ul><li><div style="text-align:'. $options['alignpic'] .
';">' . $bp_profile_pix . '</div></li><li>' . $aboutmeauthordesc .'</
li></ul>';
echo $after_widget;
}
register_sidebar_widget('About Me', 'widget_aboutme');
register_widget_control('About Me', 'widget_aboutme_control', 300,
180);
}
add_action('widgets_init', 'widget_aboutme_init');
?>
More information about the buddypress-dev
mailing list