21
haryadoon
Re: Registration/Membership Management Question
  • 2004/8/20 4:47

  • haryadoon

  • Just popping in

  • Posts: 10

  • Since: 2004/7/29


Many thanks for your ideas ! I've used them for my own customisations.

I need to allow the user to subscribe or unsubscribe to a particular group. This group allows me to send specific emails to people who want to get that type of email. The new user registration page needs to include a field to opt in or out. The user edit page ("edit account" or "edit profile") must allow the user to change this selection. When the user selects "yes", the code needs to add this user to the group; if the user selects no, the code needs to remove the user from the group.

Here's what I did :

1. include/registerform.php, around line 82:
Quote:
...
$reg_form->addElement(new XoopsFormPassword(_US_PASSWORD, "pass", 10, 32), true);
$reg_form->addElement(new XoopsFormPassword(_US_VERIFYPASS, "vpass", 10, 32), true);

// 17 Aug 2004 - Charles Thompson
// Added "Junior Club Weekly Draw"
$jr_draw_email = isset($HTTP_POST_VARS['jr_draw_email']) ? $HTTP_POST_VARS['jr_draw_email'] : "1";
$reg_form->addElement(new XoopsFormRadioYN("Do you wish to receive the weekly Junior Club draw by email ?",
"jr_draw_email", $jr_draw_email));
// end change - 17 Aug 2004 - Charles Thompson

$reg_form->addElement(new XoopsFormRadioYN(_US_MAILOK, 'user_mailok', 1));
if ($xoopsConfigUser['reg_dispdsclmr'] != 0 && $xoopsConfigUser['reg_disclaimer'] != '') {
...

This code sets up the new user registration form. Here, I add a new form row after the password row, before the "okay to send mail" row. The new row includes a prompt and a yes/no radio group. I hard-coded the text in English; I should have added this to language/english/user.php and referenced it here, but I couln't be bothered. The field name, jr_draw_email will contain a 1 for yes or a 0 for no, and is referenced in the next bit of code ...

2. register.php, around line 153 :
Quote:
...
$user_viewemail = isset($user_viewemail) ? intval($user_viewemail) : 0;

// 17 Aug 2004 - Charles Thompson
// Added "jr_draw_email" below
echo "








";
// end change - 17 Aug 2004 - Charles Thompson
// CloseTable();
} else {
...

This is the block that sets up the form post variables, which will be posted back to this program when the user submits the form. All I have done here is add a hidden field for the yes/no value selected by the user -- $jr_draw_email.

3. register.php, around line 220 :
Quote:
...
echo _US_REGISTERNG;
include 'footer.php';
exit();
}
// 17 Aug 2004 - Charles Thompson
// If user wants to belong, add user to group "Junior Weekly Draw"
if ($jr_draw_email == 1) {
$gid = 5; // change this some time so that it calls member->getGroup to find the correct ID
$member_handler->addUserToGroup($gid, $newid);
}
// end change - 17 Aug 2004 - Charles Thompson

if ($xoopsConfigUser['activation_type'] == 1) {
redirect_header('index.php', 4, _US_ACTLOGIN);
...

This is in the block that processes the submitted form fields. $jr_draw_email is populated automatically from the form POST values, from the hidden field added in (2) above. addUserToGroup is defined in kernel/member.php. I have hard-coded the group ID because I can't find an easy way to get a group ID from a text string (the group name). Remember, a value of 1 means the user wants to join the group.

4. edituser.php, around line 117 :
Quote:
...
} else {
setcookie($xoopsConfig['usercookie']);
}

// 17 Aug 2004 - Charles Thompson
// If user wants to belong, add user to group "Junior Weekly Draw"
$gid = 5; // change this some time so that it calls member->getGroup to find the correct ID
$groups =& $xoopsUser->getGroups();
if ($jr_draw_email == 1) {
if (!in_array($gid, $groups)) {
$member_handler->addUserToGroup($gid, $uid);
}
} else {
if (in_array($gid, $groups)) {
$uid_arr = array($uid);
$member_handler->removeUsersFromGroup($gid, $uid_arr);
}
}
// end change - 17 Aug 2004 - Charles Thompson

if (!$member_handler->insertUser($edituser)) {
include XOOPS_ROOT_PATH.'/header.php';
...

Unlike the registration form, the edit profile page is processed with just one php file - edituser.php. This section of code is executed when the user saves the updated details. Again, I hard-coded the group ID, and again, I use getGroups and addUserToGroup, as described above. removeUsersFromGroup is found in kernel/member.php. It requires an array of users.

5. edituser.php, around line 225 :
Quote:
...
$form->addElement($pwd_tray);
$form->addElement($cookie_radio);

// 17 Aug 2004 - Charles Thompson
// Add "Jr Club Weekly Draw" option
$groups =& $xoopsUser->getGroups();
// Group 5 is "Junior Club Weekly Draw"
// ths will need to be fixed some time in the future
$jr_draw_email_val = in_array('5', $groups) ? '1' : '0';
$jr_draw_email = new XoopsFormRadioYN(
"Do you wish to receive the weekly Junior Club draw by email ?",
"jr_draw_email", $jr_draw_email_val);
$form->addElement($jr_draw_email);
// end change - 17 Aug 2004 - Charles Thompson

$form->addElement($mailok_radio);
$form->addElement($uid_hidden);
...

Later in edituser.php, we find the code that displays the form for the user to edit. Again, I hard-coded the group ID and prompt text (see above).

Please note that the group membership changes don't seem to appear until the user logs out and back in again. I can't work out why that is ! After changing the group membership this way, the admin can see the user really is attached to the group (using the admin/groups page).

Can anyone help with my two problems :
1. How to get the group ID from the group name (without going straight to the database) ?
2. How to avoid logging out and in again in order for the user to see this change in group membership ?

22
irmtfan
Re: Registration/Membership Management Question
  • 2004/8/20 5:26

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


Quote:
need to allow the user to subscribe or unsubscribe to a particular group.

great !
can u release a package for this hack?? (when it completed)
its really needed

23
rossi
Re: Registration/Membership Management Question
  • 2004/8/23 22:28

  • rossi

  • Just popping in

  • Posts: 26

  • Since: 2004/3/24


Dear MisterB,
Don't forget to rename your register.php file becouse hiding all links form the your site doesn't prevent anyone from typing http://your_site/register.php in their adressbar and hiting enter:). Moreover I suggest hardcoding your register.php and add some kind of dinamical hashing in the links you'll send to people you like join in:

1. Create hash md5/sha1/rand
2. Put the hash in Data Base
3. Send email:
"Dear visitor you can register on mysite/new_name_of_register.php?hash=the_generated_hash_code"
4.Automatically remove from Data Base the hash_code after user has the reg.

Cheers!

24
jegelstaff
Re: Registration/Membership Management Question

Hello,

I know this hasn't been asked about specifically in this thread, but I thought that if anyone is dealing with the management of new users in a site that has strict group membership rules, then you might benefit from a module we have made called Registration Codes, or from a similar module called Registration Keys. These modules let you create a code that is associated with certain groups in your system and then new users can enter that code when they create their account and they will automatically be made members of the groups you specified.

You can find out more about our Registration Codes module here:

https://xoops.org/modules/newbb/viewtopic.php?topic_id=23504&forum=14

The Registration Keys module is available in the Downloads section:

https://xoops.org/modules/mydownloads/singlefile.php?cid=24&lid=581

Happy XOOPSING,

--Julian

25
carrie
Re: Registration/Membership Management Question
  • 2004/8/25 20:02

  • carrie

  • Just popping in

  • Posts: 58

  • Since: 2003/6/12


Quote:

ccunltd wrote:
When I got to step 3, I could not find the define information to change in the user.php file. Was I suppose to add this information?


Quote:
3. In ../user.php

define('_US_ICQ','Organisation');
define('_US_AIM','Department');
define('_US_YIM','Address');
define('_US_MSNM','City');
define('_US_LOCATION','County');
define('_US_OCCUPATION','Post Code');
define('_US_INTEREST','Phone');


Has anyone figured out an answer to this question yet? I'm trying to change some fields too, but I don't quite understand what you are supposed to change in the user.php file. Thanks.

26
damjam
Re: Registration/Membership Management Question
  • 2004/8/25 22:23

  • damjam

  • Just popping in

  • Posts: 63

  • Since: 2004/3/30


I don't know if a previous version defined those fields in user.php but they're not defined there in 2.0.5.2 so I disregarded item 3.

There's a bit about it here:

https://xoops.org/modules/newbb/viewtopic.php?topic_id=23144&forum=15#forumpost101472

I have it working fine on my site.

27
carrie
Re: Registration/Membership Management Question
  • 2004/8/26 17:32

  • carrie

  • Just popping in

  • Posts: 58

  • Since: 2003/6/12


I'm using version 2.0.7.1 and it's doesn't have them either. I will check out the thread that you gave. Thanks.

28
webguygary
Re: Registration/Membership Management Question
  • 2004/12/2 15:10

  • webguygary

  • Just popping in

  • Posts: 25

  • Since: 2004/11/8


This thread has been very informative, but now that it's been running all these months on this topic, has anyone developed a module or hack for letting users select which group they wish to belong to while on the registration page?

Thanks.

29
webguygary
Re: Registration/Membership Management Question
  • 2004/12/15 16:29

  • webguygary

  • Just popping in

  • Posts: 25

  • Since: 2004/11/8


Quote:

ReCkage wrote:
I had someone create a feature that the user places themselves in a group guring registration. It ask the user what group they belong to and places them in it.

Keep looking in the hacks, for the next few days, I will get them to also write up on how to edit and add features to the registration menu.


That would be an excellent hack if you could either post it or direct us to where the hack is located.

30
gtop00
Re: Registration/Membership Management Question
  • 2004/12/16 17:12

  • gtop00

  • Friend of XOOPS

  • Posts: 498

  • Since: 2004/11/13


Dear All,

I have the same request as many others as it seems!

Please have a look at "module requests": https://xoops.org/modules/newbb/viewtopic.php?topic_id=28344&forum=30

I see that changing some fields in the registration page can "solve" somehow the problem but be carefull, it is not legal to leave members data in common view!

Quote:

(*) Important: Please note that public access on some of these data is protected by law, so they must be only viewed and edited by the member itself and/or the portal administrator.

Login

Who's Online

463 user(s) are online (402 user(s) are browsing Support Forums)


Members: 0


Guests: 463


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits