News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Restrict forum access based upon birthday

Started by jdougher, July 23, 2005, 08:54:50 AM

Previous topic - Next topic

jdougher

Can I restrict access to a particular forum on my site http://www.photocamel.com based upon the birthday that a user enters? I'm trying to figure out an elegant, easy way for me to have ONE forum available only to people over 18. Thanks. This is a problem that's really pestering me and is fairly urgent.

Furvert

I too would love to see a solution using this directly.
I currently manually set people to an adult membergroup with different permissions which does require some effort on my part and delays to the user.

Unfortunately I think this would require a database mod to enable age as a permission setting.

Of course if they can edit birthday, they can set themself adult and change back later! It would be nice if it was locked out from reeditting somehow?

jdougher

Quote from: Furvert on July 24, 2005, 07:36:19 PM
I too would love to see a solution using this directly.
I currently manually set people to an adult membergroup with different permissions which does require some effort on my part and delays to the user.

Unfortunately I think this would require a database mod to enable age as a permission setting.

Of course if they can edit birthday, they can set themself adult and change back later! It would be nice if it was locked out from reeditting somehow?

You and I are in the same boat. I would think this should be a feature.

Furvert

I am looking into what code is required.
I wanted to add age to memberlist as well, so I am trying to code that as a test.
'age' appears to be defined in the database on people, or at least something in profiles assigns it temporarily. Either way that code should be usable.

Ben_S

Have a look at http://www.simplemachines.org/community/index.php?topic=43141.0

It may help, although it has some limitations as I mention in that post.
Liverpool FC Forum with 14 million+ posts.

Furvert

I now have AGE added to the memberlist display and working for sorts as well.
Mods to 'Memberlist.php' in source
Mods to 'Memberlist.template.php' in default theme

It wasn't difficult other than I could not use the language defined 'Age' in $txt[420] for the column title, so put it in English for now. $txt[420] is used by profiles.english.php but the code grabs from index.english.php where I though it was global?

Maybe someone knows how to fix this properly for best compatability.

http://furvert.net/smf/index.php
test/test

If others desire this mod I can try to make instructions

jdougher

Quote from: Furvert on July 24, 2005, 10:23:13 PM
I now have AGE added to the memberlist display and working for sorts as well.
Mods to 'Memberlist.php' in source
Mods to 'Memberlist.template.php' in default theme

It wasn't difficult other than I could not use the language defined 'Age' in $txt[420] for the column title, so put it in English for now. $txt[420] is used by profiles.english.php but the code grabs from index.english.php where I though it was global?

Maybe someone knows how to fix this properly for best compatability.

http://furvert.net/smf/index.php
test/test

If others desire this mod I can try to make instructions

Yes, I would love instructions. Thanks.

Furvert

Ok, I tried to write it in the 'mod' format, dont see a post file option so have to do it inline.
One thing that needs fixing is 'label' => 'Age' but that requires another file mod to add $txt[] somewhere so that it can be updated for languages.

AgeInMemberlist_11b3p.mod

<id>
AgeInMemberlist_11b3p
</id>

<version>
1.1b3p
</version>

<mod info>
Add member age to the memberlisting with sorting.
</mod info>

<author>
Furvert
</author>

<homepage>
http://furvert.net/smf/
</homepage>

<edit file>
Sources/Memberlist.php
</edit file>

<search>
'realName' => array(
'label' => $txt[35]
),
</search>

<replace>
'realName' => array(
'label' => $txt[35]
),
'age' => array(
'label' => 'Age'
),
</replace>

<search>
'realName' => array(
'down' => 'mem.realName ASC',
'up' => 'mem.realName DESC'
),
</search>

<replace>
'realName' => array(
'down' => 'mem.realName ASC',
'up' => 'mem.realName DESC'
),
'age' => array(
'down' => 'mem.birthdate ASC',
'up' => 'mem.birthdate DESC'
),
</replace>

<edit file>
Themes\default\Memberlist.template.php
</edit file>

<search>
foreach ($context['members'] as $member)
</search>

<replace>
foreach ($context['members'] as $member)
{
if (empty($member['birth_date']))
{
$member +=  array(
'age' => &$txt[470],
);
}
else
{
list ($birth_year, $birth_month, $birth_day) = sscanf($member['birth_date'], '%d-%d-%d');
$datearray = getdate(forum_time());
$member += array(
'age' => empty($birth_year) ? $txt[470] : $datearray['year'] - $birth_year - (($datearray['mon'] > $birth_month || ($datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day)) ? 0 : 1),
);
}
</replace>

<search>
<td class="windowbg" align="left">', $member['link'], '</td>
</search>

<replace>
<td class="windowbg" align="left">', $member['link'], '</td>
<td class="windowbg" align="right">', $member['age'], '</td>
</replace>

<search>
}
// No members?
</search>

<replace>
}
}
// No members?
</replace>

jdougher

Thanks! so this is not "good to go," right?

Furvert

You can do the edits as shown manually, I do not know how to make a package version.
Someone may be able to take that mod file and do it though, as I think it needs some xml to work?
I could be wrong on that.

I have been using it since I made it with no problems so I dont expect others will have any. If someone uses other language files, the 'Age' label will stay in english as I have not fixed that aspect yet. The profiles.english.php has the word 'age' defined but it did not access it for $txt[420] like I expected it to. If it had then other language packs should have worked.

jdougher

Quote from: Furvert on July 25, 2005, 09:59:13 PM
You can do the edits as shown manually, I do not know how to make a package version.
Someone may be able to take that mod file and do it though, as I think it needs some xml to work?
I could be wrong on that.

I have been using it since I made it with no problems so I dont expect others will have any. If someone uses other language files, the 'Age' label will stay in english as I have not fixed that aspect yet. The profiles.english.php has the word 'age' defined but it did not access it for $txt[420] like I expected it to. If it had then other language packs should have worked.

Thanks. I hope I can figure out how to insert this.


Furvert

See http://www.simplemachines.org/community/index.php?topic=43818.0
I changed to a new topic for code help

With a little help I think I can write this

Furvert

In a related MOD, I added 'Last Login' to Memberlist with sorting as a means to determine how active members are. If someone wants it I can write a MOD file for it like the AGE MOD. It was quite similar except for a timestamp conversion needed.

I have partial code on the AGE restriction by Board. I need to write the admin panel yet. Hopefully I will get a chance to work on it soon.

Advertisement: