1 (edited by Peter 2007-10-29 17:36)

Topic: Force everybody to use avatars, lock use_avatar to 1

I want to "force" all my members to use avatars, because I have a customized punbb with a "no picture" picture that shows up when there's no avatar available. That gives members enough choice; if they don't want to upload a picture, they get the "no picture" badge of shame. ;-)

I changed the existing zeroes into ones with this query:

UPDATE users SET use_avatar = 1

How can I permanently lock use_avatar to 1? Or entirely remove the check from the code?

2

Re: Force everybody to use avatars, lock use_avatar to 1

Why not just alter:

$user_avatar = $lang_topic['No avatar'];

in the relevant files to supply an avatar rather than just a 'no avatar' text. Or, make the 'No avatar' entry in lang/topic.php an img entry for a default avatar?

3 (edited by Peter 2007-10-29 21:56)

Re: Force everybody to use avatars, lock use_avatar to 1

Thanks MattF, but that part is already sorted out.

My problem is that even if you upload a picture, it only shows up if the user selects "Use avatar" (use_avatar in MySQL). This setting is hidden somewhere in PunBB's vague multilevel profile editing menus.

I want to simplify it; upload a picture and the picture shows up. Don't want a picture? Delete it and you'll get the "no picture" default. I want to take "use_avatar yes or no" out of the equation or at least make it default yes.

Re: Force everybody to use avatars, lock use_avatar to 1

If you upload a picture, use is set to yes. If you delete a picture, it's set to no. If you want to remove it, simply search for the code in profile.php

5 (edited by MattF 2007-10-29 22:00)

Re: Force everybody to use avatars, lock use_avatar to 1

Do a grep for use_avatar. big_smile Where are you wanting to force the display of avatars? In viewtopic.php only?

6

Re: Force everybody to use avatars, lock use_avatar to 1

Smartys wrote:

If you upload a picture, use is set to yes. If you delete a picture, it's set to no. If you want to remove it, simply search for the code in profile.php

I use the resize-on-upload modification and I'm reorganizing the profile edit menus. I don't know why, but use_avatar does not get set automatically on upload or delete. I probably broke something, but that doesn't matter.

My question is how to take use_avatar out of the equation. Or set it to default 1. Removing all the lines that mention use_avatar from profile.php probably won't do it. Or would it?

What's a grep?

It doesn't matter where to display the avatar, I just want to make sure that whereever the code asks for an avatar it actually gets shown, that it's not sabotaged by a sneaky 0 in use_avatar.

7 (edited by MattF 2007-10-30 14:11)

Re: Force everybody to use avatars, lock use_avatar to 1

Grep is *nix tool. smile

Grep output, (your line numbering will differ):

profile.php:408:                $db->query('UPDATE '.$db->prefix.'users SET use_avatar=1 WHERE id='.$id) or error('Unable to update avatar state', __FILE__, __LINE__, $db->error());
profile.php:653:                $db->query('UPDATE '.$db->prefix.'users SET use_avatar=1 WHERE id='.$id) or error('Unable to update avatar state', __FILE__, __LINE__, $db->error());
profile.php:715:        $db->query('UPDATE '.$db->prefix.'users SET use_avatar=0 WHERE id='.$id) or error('Unable to update avatar state', __FILE__, __LINE__, $db->error());

Edit: I've only put the db update lines up, as if you're setting this value to 1 when you add a user, they're the only parts that you should need to alter, (if any).

Re: Force everybody to use avatars, lock use_avatar to 1

The last line in your grep output just needs to be deleted, that's all.

9

Re: Force everybody to use avatars, lock use_avatar to 1

Thanks. It seems obvious, but sometimes I just don't know where to start. Posting here also helps me keep track of what I'm doing and finding solutions when I need them again later.

I'll see what happens if I remove all three of these lines (and any other mentions of use_avatar I can find). I'll report back later...

10

Re: Force everybody to use avatars, lock use_avatar to 1

Peter wrote:

Thanks. It seems obvious, but sometimes I just don't know where to start. Posting here also helps me keep track of what I'm doing and finding solutions when I need them again later.

We've all been in the same boat at some point, so know what it's like. The devs on here are life savers when you're stuck with some coding issue. smile


Peter wrote:

I'll see what happens if I remove all three of these lines (and any other mentions of use_avatar I can find). I'll report back later...

As elbekko mentioned, you only need to comment out the latter of those three. The other two enable the setting anyhow, so can be left untouched. smile

11 (edited by Peter 2007-10-30 20:23)

Re: Force everybody to use avatars, lock use_avatar to 1

Thanks MattF. I'm learning a lot recently. smile

I understand the other two database lines don't hurt, but I want to try to take use_avatar out entirely. I try to simplify where possible. On the other hand I add fields. For example, I can now let members put an RSS feed on their member page. And I added a simple math captcha from sNews to my registration form.

I'll share the finished product when I have it, so you can tell me where I messed up and broke security etc. wink

Re: Force everybody to use avatars, lock use_avatar to 1

Hmm. Why haven't you just used this?
http://wiki.punres.org/Default_avatar

13

Re: Force everybody to use avatars, lock use_avatar to 1

elbekko, again, I already had a default avatar/picture. That's not what my question was about.

My question was about removing the use_avatar field (or making it at least default 1) from the users table. It doesn't seem to serve any purpose if there's a default avatar.

Re: Force everybody to use avatars, lock use_avatar to 1

No, but it's rather useless to remove it if you're using that mod wink

15

Re: Force everybody to use avatars, lock use_avatar to 1

this is my first post so dont laugh at me bu to do what you want man in the profile.php file find the code

<label><input type="checkbox" name="form[use_avatar]" value="1"<?php if ($user['use_avatar'] == '1') echo ' checked="checked"' ?> /><?php echo $lang_profile['Use avatar'] ?><br /></label>

and comment it out and then
in the database for users set the default for useravatar to be a 1 instead of a 0

the database change will set all ppl to use avatar on creation commenting out the code will hide the check mark for changing it