News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Change member group based on email address

Started by nosferatu, August 15, 2009, 02:30:30 PM

Previous topic - Next topic

nosferatu

Is it possible to change the member group of a large number of members based on their email address? Basically, I have 24 pages of members who have the same email domain (an employment email address) and I want to be able allow them special permissions, effectively validating the permissions based on email address. Can I run a sql query to amend the member group of these members and, if so, can someone tell what I need to do?

Many thanks

Nos
There's a certain joy in being mad that only madmen know

tyty1234

#1
I created a small php file just to do what you requested. However, I fear that it will take a lot of time to execute, and I haven't tested it, but it theoretically should work. You should backup your db before doing this.

All you need to do is upload the file attached to your SMF folder, then point your browser to http://yoursmfsite.com/setMemGroup.php?domain=email.com&id_group=x

You can change domain to the email domain name (ex. hotmail, yahoo etc) and must contain a valid tld extension. You can also change the id_group to the group you want to assign the members to (admins are group 1, gmods are group 2). You can find out the group id by going to the info center on your forum, clicking on the group that are displayed, and then in the url, the group id is specified by "group=x".

If anything goes wrong, let me know ASAP. :)
My Activity: Inactive
My Links: tyty1234's SMF Site | SMF Package Parser | SMF Helper | My Mods [5]
Subscribe to my SMF blog for updates
PMs for support will not be accepted, unless requested otherwise.

nosferatu

Thanks tyty. I tried running it but I simply get the following:

Parse error: syntax error, unexpected T_ARRAY in /home/southwalesuk/public_html/forum/setMemGroup.php on line 38

Any ideas? I'm running SMF 2.0 RC 1-1

Thanks for your help
There's a certain joy in being mad that only madmen know

tyty1234

My Activity: Inactive
My Links: tyty1234's SMF Site | SMF Package Parser | SMF Helper | My Mods [5]
Subscribe to my SMF blog for updates
PMs for support will not be accepted, unless requested otherwise.

nosferatu

#4
Ok. I think I may be to blame for this.

I'm now receiving the following:

An Error Has Occurred!
Wrong value type sent to the database. Integer expected. (email)

I placed the email domain in place of email.com in the address provided. Was I supposed to do something else? I also replaced the id_group=x with id_group=13 (the id of the new group)
There's a certain joy in being mad that only madmen know

nosferatu

When I changed the "domain=" part of the address to "email=", I had a blank screen returned.
There's a certain joy in being mad that only madmen know

tyty1234

no, it should be domain, not email.
but it was the part in the query near {int:email}. I changed it to {string:email} see if that works.
My Activity: Inactive
My Links: tyty1234's SMF Site | SMF Package Parser | SMF Helper | My Mods [5]
Subscribe to my SMF blog for updates
PMs for support will not be accepted, unless requested otherwise.

nosferatu

Nope, sorry tyty. It now states:

Database Error
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@the email domain.uk' at line 3
File: /home/southwalesuk/public_html/forum/setMemGroup.php
Line: 60
There's a certain joy in being mad that only madmen know

tyty1234

Try removing the @ symbol...did you use that symbol in the domain field anyway?
My Activity: Inactive
My Links: tyty1234's SMF Site | SMF Package Parser | SMF Helper | My Mods [5]
Subscribe to my SMF blog for updates
PMs for support will not be accepted, unless requested otherwise.

nosferatu

I hadn't but I've now tried that and get exactly the same error. Each of these members (740 odd) is currently not allocated to any primary group. Is there no SQL query that could be run to apply a group to them?
There's a certain joy in being mad that only madmen know

Arantor

If it's just primary group, assuming your members table is called smf_members, and the new group is group 5 (say)
UPDATE smf_members SET id_group = 5 WHERE email_address LIKE '%@domain.com';

Advertisement: