Advertisement:

Author Topic: Default Avatar On Registration  (Read 30730 times)

Offline ScoobyDan

  • Semi-Newbie
  • *
  • Posts: 11
  • Gender: Male
  • Nemo Mortalium Omnibus Horis Sapit
    • Buff Chat - The Online Community of The RAOB
Default Avatar On Registration
« on: June 23, 2007, 07:44:09 PM »
I created this modification so that all new users have a default avatar selected (which they can then change if they wish). I feel this makes the forum look far better than some users having an avatar and some not. This is different to the Default Avatar tip, which 'fakes' a default avatar by changing the templates to insert an avatar if one does not exist in the database.

To implement this tip, simply edit Sources/Register.php, and find

Code: [Select]
// Include the additional options that might have been filled in.
foreach ($possible_strings as $var)
if (isset($_POST[$var]))
$regOptions['extra_register_vars'][$var] = '\'' . $func['htmlspecialchars']($_POST[$var]) . '\'';

(lines 286-289 on my v1.1.2 forum). Add the following after the above:

Code: [Select]
// Default Avatar On Registration Mod Start
$regOptions['extra_register_vars']['avatar'] = '\'avatar.gif\'';
// Default Avatar On Registration Mod End

(amend 'avatar.gif' to point to your default avatar file, stored in the 'avatars' folder).

That's it! Job done. :D

Mods: If suitable, please move this to the 'Tips & Tricks' forum. Thanks ;)

Offline codenaught

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 14,653
  • Gender: Male
  • Formerly Known As akabugeyes
Re: Default Avatar On Registration
« Reply #1 on: June 23, 2007, 07:57:37 PM »
Thanks for sharing. :)

Moving to Tips and Tricks...
Dev Consultant
Former SMF Doc Coordinator

Offline lonrot

  • Jr. Member
  • **
  • Posts: 334
Re: Default Avatar On Registration
« Reply #2 on: June 27, 2007, 04:20:20 PM »
Excellent trick ScoobyDan, works like a charm!

Offline perro88

  • Jr. Member
  • **
  • Posts: 358
    • techcoreforum
Re: Default Avatar On Registration
« Reply #3 on: August 06, 2007, 12:05:10 AM »
Nice just a line on code but very useful hehe

elfishtroll

  • Guest
Re: Default Avatar On Registration
« Reply #4 on: August 12, 2007, 10:09:34 PM »
Nice just a line on code but very useful hehe

ditto on that! I can use it to default other fields as well on registration :)

Offline MichaelMorris

  • Semi-Newbie
  • *
  • Posts: 27
  • Gender: Male
    • Michael Morris Design
Re: Default Avatar On Registration
« Reply #5 on: August 27, 2007, 11:03:50 AM »
Howdy.

Ok, im going to use your code to set the default avatar, but what I would aslo like is this:

The user joins the forum and their avatar is set. The moderator of the forum then changes their membergroup (so they have access to extra parts of the forum). If the user didnt change their avatar from when it was set on registration, then I would like it to change to an avatar for that group, but if they have changed it then just leave it.

Is this possible????

Thanks in advance
Michael.

Offline Goatie

  • Semi-Newbie
  • *
  • Posts: 13
  • Gender: Male
    • GoatLog
Re: Default Avatar On Registration
« Reply #6 on: September 03, 2007, 05:49:34 AM »
Great, thanks for the tip....
I can't believe I had to register at the forums before I found this tip. I couldn't even find it by searching the forums >_<
But once again.. Thanks!!

Offline codenaught

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 14,653
  • Gender: Male
  • Formerly Known As akabugeyes
Re: Default Avatar On Registration
« Reply #7 on: September 03, 2007, 04:43:42 PM »
Great, thanks for the tip....
I can't believe I had to register at the forums before I found this tip. I couldn't even find it by searching the forums >_<
But once again.. Thanks!!
The Tips and Tricks board is viewable by guests. I just logged out and could still see it. Just saying this because you seem to suggest otherwise.

@MichaelMorris, do you mean you want to have different avatars for those that have no avatar of there own, depending on what group the user is in?

If so, I would advise you to take a look at this - http://www.simplemachines.org/community/index.php?topic=19500.0. And adapt it to meet your needs.

Basically I think you would want to change the:

Code: [Select]
'/noava.gif"
Bit of code to include the group ID:

Code: [Select]
'/noava.gif_' . $message['member']['group_id'] . '"
And then you would have images with names reflecting the group ID.

Such as: noava_0.gif for regular members, noava_1.gif for admins, noava_2.gif for global mods, etc.
Dev Consultant
Former SMF Doc Coordinator

Offline Goatie

  • Semi-Newbie
  • *
  • Posts: 13
  • Gender: Male
    • GoatLog
Re: Default Avatar On Registration
« Reply #8 on: September 04, 2007, 09:11:13 AM »
The Tips and Tricks board is viewable by guests. I just logged out and could still see it. Just saying this because you seem to suggest otherwise.
Ah sorry, I'm just not so good at looking the right places :-[

Offline MichaelMorris

  • Semi-Newbie
  • *
  • Posts: 27
  • Gender: Male
    • Michael Morris Design
Re: Default Avatar On Registration
« Reply #9 on: September 05, 2007, 04:55:49 AM »
@akabugeyes

Yea, thats perfect. Thanks!

Offline Cavan

  • Semi-Newbie
  • *
  • Posts: 40
Re: Default Avatar On Registration
« Reply #10 on: September 09, 2007, 11:32:08 AM »
How would I use this tip for users already registered? I have avatars set to display in the memberlist, so I'd like the default avatar to show up there for my previously registered users.
« Last Edit: September 09, 2007, 02:44:24 PM by Cavan »

Offline codenaught

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 14,653
  • Gender: Male
  • Formerly Known As akabugeyes
Re: Default Avatar On Registration
« Reply #11 on: September 09, 2007, 12:07:35 PM »
It can sort of depend what code you are using. There is another trick posted that explains how to show a default avatar for all members without an avatar (which doesn't take into account when the member registered), however that doesn't mention anything about the memberlist (mainly because the avatar is not shown there by default).

If you let us know some of the code you are using, possible files custom code may be in would likely include: Memberlist.php and Memberlist.template.php.
Dev Consultant
Former SMF Doc Coordinator

Offline Cavan

  • Semi-Newbie
  • *
  • Posts: 40
Re: Default Avatar On Registration
« Reply #12 on: September 09, 2007, 03:01:19 PM »
I'm using 1.1.3 and the orange-lt theme. I should also note that I only allow users to upload an avatar; I don't allow access to externally stored avatars nor do I let them select one from the www/avatars folder.

In www/Sources/Memberlist.php I have:

Code: [Select]
// Set up the columns...
$context['columns'] = array(
'isOnline' => array(
'label' => $txt['online8'],
'width' => '20'
),
'avatar' => array(
            'label' => 'Avatar'
        ),

In www/Themes/default/Memberlist.template.php I have:

Code: [Select]
// Assuming there are members loop through each one displaying their data.
if (!empty($context['members']))
{
foreach ($context['members'] as $member)
echo '
<tr style="text-align: center;"', empty($member['sort_letter']) ? '' : ' id="letter' . $member['sort_letter'] . '"', '>
<td class="windowbg2">
', $context['can_send_pm'] ? '<a href="' . $member['online']['href'] . '" title="' . $member['online']['text'] . '">' : '', $settings['use_image_buttons'] ? '<img src="' . $member['online']['image_href'] . '" alt="' . $member['online']['text'] . '" align="middle" />' : $member['online']['label'], $context['can_send_pm'] ? '</a>' : '', '
</td>
<td class="windowbg" align="center" width="100px">',$member['avatar']['image'], '</td>
<td class="windowbg" align="left">', $member['link'], '</td>

I've been trying to get this to work in Memberlist.template.php by calling my default avatar (def_avatar.gif)  but I'm not sure how to distinguish between an uploaded avatar and one that's stored on the server (in this case).

I've tried inserting this bit of code from Profile.template.php but I played around with it and can't seem to make it work in Memberlist.template.php:

Code: [Select]
// This is the avatar selection table that is only displayed if avatars are enabled!
if (!empty($context['member']['avatar']['allow_server_stored']) || !empty($context['member']['avatar']['allow_upload']))

Any ideas? Thanks.
« Last Edit: September 09, 2007, 03:03:10 PM by Cavan »

Offline Fiery

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,209
  • Gender: Male
  • Community Builder
Re: Default Avatar On Registration
« Reply #13 on: October 10, 2007, 12:00:42 AM »
Were you able to get this working?

What about on the default theme, just to check to see if everything was done correctly?

Offline The -L-

  • Jr. Member
  • **
  • Posts: 353
Re: Default Avatar On Registration
« Reply #14 on: June 21, 2009, 04:03:07 PM »
What if i have 1.1.9 version???

Offline H

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 21,660
  • Gender: Male
Re: Default Avatar On Registration
« Reply #15 on: July 08, 2009, 04:36:02 PM »
This should not need changes to work on 1.1.9
-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)