Recent Topics

1 Jan 02, 2009 15:55    

My b2evolution Version: 2.4.5
Hi @lltogether,

happy new year to all of you!

I´m having a problem here:
For a multi-user site I shall realize Gravatars in the comments - I know there is a plugin (I use it on my site), but in this case, no uploads are allowed, so the plugin can´t be used.

I already modified _item_comment.inc.php to show gravatars for non-registered (not logged-in) users, easy so far. But if a user is logged in and posts a comment, his mail-address is NOT written to the database and therefore no gravatar will be shown in the comments.

Already fooled around a bit with _item_comment_form.inc.php but couldn´t get it working. Is there a way to write loggen-in users mail-address into the database and how can this be done?!?

Would be very glad if some of you cracks could help me outta here...
Thx a lot!

Greetings from Germany
Joshua

2 Jan 02, 2009 17:34

off the top of my head :

<?php
$email = $Comment->get_author_email();
?>

¥

3 Jan 02, 2009 17:52

Thanks for your answer - but this


<?php
$email = $Comment->get_author_email();
?>


gives back a complete link including mailto:
So it don´t work, I already tried this.

Cheers,
Joshua

EDIT:
That´s how I modified _item_comment.inc.php


$grav_url = "http://www.gravatar.com/avatar.php?gravatar_id=".md5($Comment->author_email); ?>
	<div style="float:left"><img class="show_gravatar" src=<?echo $grav_url;?> width="60" height="60" /></div>

And I had to append some code to the css-file:


/* Gravatar style */
img.show_gravatar {
	margin:7px;
	padding:1px;
	border:1px solid #CCCCCC;
	background-color:white;
}

4 Jan 03, 2009 11:04

it's never the easy answer :P

<?php
if( $Comment->author_ID )
{
	$Comment->get_author_User();
	$email = $Comment->author_User->get( 'email' );
}
else
{
	$email = $Comment->author_email;
}
?>

¥

5 Jan 03, 2009 11:19

Once again thanks for your answer - but it don´t work either. :-(

For registered users it gives back NULL for $email whereas as non-registered users mail-address is shown correctly.

I guess $Comment_>author_ID is NULL in _item_comment.inc.php...

Already tried to substr ( $Comment->author_email(), 7) but it also gives back NULL.

Confused... :-\

Thx again.

Cheers,
Joshua

6 Jan 03, 2009 11:27

Next attempt ;)

if( !empty( $Comment->author_User ) )
{
    $email = $Comment->author_User->get( 'email' );
}
else
{
    $email = $Comment->author_email;
}

¥

7 Jan 03, 2009 11:34

Perfect!
This one

if( !empty( $Comment->author_User ) )
{
    $email = $Comment->author_User->get( 'email' );
}
else
{
    $email = $Comment->author_email;
}


works really fine!
Gravatars are now displayed for all -registered and non-registered- users, below ist how the _item_comment.inc.php looks now:


	<?php $Comment->rating();
		if( !empty( $Comment->author_User ) )
		{
			$email = $Comment->author_User->get( 'email' );
		}
		else
		{
			$email = $Comment->author_email;
		}
	$grav_url = "http://www.gravatar.com/avatar.php?gravatar_id=".md5($email); ?>
	<div style="float:left"><img class="show_gravatar" src=<?echo $grav_url;?> width="60" height="60" /></div>	
	<div class="bCommentText">
		<?php $Comment->content() ?>
	</div>

Thanks so much ¥åßßå!!!

Cheers,
Joshua


Form is loading...