Hello,

Wow, this module extends the OG functionality quite a bit! Nice work!

I was wondering if there is a way to automate the Invitation process for "Invite-only" groups. Right now when a group is Invite-only, and the group admin clicks on "Invite friend" link, the default URL takes them to an Access Denied page (http://dev.site.net/og/subscribe/2178).

The alternative is for the admin to take a code and manually send a private message to the member, then have that member come to a code submission page and enter the code. Then the user can potentially invite others, so the to keep the group invite rights, admin has to come up with a list of codes and auto-expire them after each use.

This somehow seems less than ideal.

I'm wanting to replicate the standard invite-only group functionality a la Flickr, where all a group admin has to do is click "Invite friend", enter the username and click Send. And all the user has to do is click on a link in the automatically generated email with a unique code.

Has anyone seen anything like that being developed? If not, I would like to develop that, as it's a much needed functionality for our community portal.

Here's the basic idea:
* Replace the code-entering interface on group page edit form with a simple ON/OFF checkbox.
* Create an interface where the invite code can be taken from the url (/og/GID/join/asdf89u98309u23r).
* Auto-generate the registration code upon a new invite and store it like a regular code.
* Include the URL with the invite code in the invitation email.
* Trigger the code auto-delete sequence when user joins.

Many parts of this are already in place, so it seems like it is quite doable to extend the functionality.

Any ideas on where to start?

Best,
Andrey.

Comments

somebodysysop’s picture

If I understand you, you wish to replace the current "Registration Code" functionality in OGR with an auto-generated code that works in conjunction with the "invite friend" feature.

Currently when you click on the "invite friend" link, you can enter a "Personal message:". In this personal message, you can enter a code that can be used by these individuals to register and automatically subscribe to the group.

The current "Registration Code" functionality, in my opinion, is not automated in the way you suggest, but far more robust in terms of accomodating a variety of circumstances. For this reason, I would not be inclined to replace it with your suggestion.

mr.andrey’s picture

Hi @SomebodySysop,

I see you point. It's more flexible in a sense that other members and not just admins can invite users, and it's up to the admin to decide... other ways too. Though a bit more complex. I was thinking of extending the functionality to have auto-codes as an additional option.

One problem with the current setup is when you send the invite, the email says to go to og/subscribe/GID, and if the group is invite-only, it gives Access Denied. I wonder if there is a way to change the !group_url token to make it go to the "enter code" page when group is invite-only or have "enter code" as an option on the same page? Or maybe have a special invite page for invite-only groups that changes the message...

Any ideas?

Thanks,
Andrey.

somebodysysop’s picture

The URL to enter a registration code is: og/regcode

As in: http://www.yoursite.com/og/regcode

So, use that URL instead of !group_url token in Organic Groups Configuration (admin/og/og), Admin->Organic groups->Email settings->Invite user email body.

This will work for authenticated users. When anonymous users get to this page, they will see a link which says that they must register/login to use registration code. By following this link, they will get to the registration page which will display the option to enter a registration code. Note that "anonymous" users must have the "use registration codes" permission for this to work.

Also there is a "Register Codes" block available for use by authenticated users. It only appears when you:

a. Place the block, titled "Register Codes", someplace on your page, preferably underneath the Group Details block
b. In OGR Settings, place check in "Allow Group Admins to set Registration Codes", then Save configuration.
c. In the group Edit page form for the desired group(s), place check in "Set registration codes to allow users to join this group?". Then, enter the code(s) to be used.
d. In Access Control, give authenticated users the "use registration codes" permission.

Now, when an authenticated user comes to the group home page, he will see the "Enter registration code" link.

Hope this helps.

Details on using Registration Codes are here: http://drupal.org/node/217229

mr.andrey’s picture

Many thanks, this is very helpful.

mr.andrey’s picture

Hi there,

One problem here is that some groups use reg codes and some don't. The !group_url token is the one needed for non-reg-code groups and the og/regcode is needed for reg-codes ones.

The only workaround I see at the moment is to include the regcode block on the "content top" on the og/subscribe/GID page. This way groups with no reg codes will just join, and users with reg codes will get the block, though they will also get the Access Denied error right below that, which is less than ideal.

Is there another way to have both work in a more intuitive and simple way?

Thanks,
Andrey.

somebodysysop’s picture

The only workaround I see at the moment is to include the regcode block on the "content top" on the og/subscribe/GID page. This way groups with no reg codes will just join, and users with reg codes will get the block, though they will also get the Access Denied error right below that, which is less than ideal.

Where exactly does a user get an "Access Denied" message in this process? I've not seen this.

mr.andrey’s picture

If the user wants to join a reg-code invite-only group through og/subscribe/GID, they will get an Access Denied error.

If the user wants to join a non-reg-code open group through og/regcode, they have no code, so they can't join.

What URL should I use in the invite email? Members will want to send invites to both reg-code and non-reg-code groups.

Andrey.

somebodysysop’s picture

If the user wants to join a reg-code invite-only group through og/subscribe/GID, they will get an Access Denied error.

Any idea why they are getting this error here? Is the regcode block causing it?

mr.andrey’s picture

The error is simply due to the group being an invite-only group. It's supposed to give Access Denied because users can't join invite-only groups. Putting the OGR block on top of the page gives users the option to enter the reg code, but it doesn't make the error go away.

So the question here is what URL to give to the users in the automatic invite emails? og/subscribe/GID doesn't work for regcode/invite-only groups, and og/regcode doesn't work for non-regcode/open groups.

Andrey.

mr.andrey’s picture

Version: 5.x-2.8 » 5.x-3.1

Changing this to 3.1, since that's what I'm using now.

somebodysysop’s picture

So the question here is what URL to give to the users in the automatic invite emails? og/subscribe/GID doesn't work for regcode/invite-only groups, and og/regcode doesn't work for non-regcode/open groups.

My recommendations:

1. As the OG maintainer to make the invite email section configurable by group as opposed to a default for all groups. If that doesn't work:

2. Create a page. Make it public. Put two links on it: One for regcode/invite-only groups and one for non-regcode/open groups. In the invite email, point to this page with something like:

http://www.yoursite.com/node/nid?sub=gid

Write some PHP to configure to grab the "sub" value ($gid = $_GET['sub'])

Insert the $gid value into the og/subscribe/gid link.

There you have it: One page to cover both circumstances.

mr.andrey’s picture

Thanks for the info.

I was actually thinking of doing a _form_alter on the invite form, putting all of the text into the personal message textbox, and doing a check to see if the group uses regcodes. If it does, give one link, if not give another.

This way the admins can customize their invite text as they want, and there is a proper link for each case. I think I'll also do a check-if-group-admin and give the actual reg-code values so they are handy.

Andrey.

mr.andrey’s picture

This is what I have for the form alter. It's a rather specific example to my particular configuration, but I think it's very thorough in terms of holding the group admin's hand through different cases.

  if ($form_id == 'og_invite_form') {
    $gid = $form['gid']['#value'];
	$node = node_load($gid);
	global $user;
		
	$message = "Hey there TT member,\n\n"
			   ."This is an invitation to join the group '".$node->title."\n\n"
			   ."Please see the link and message below.\n\n"
			   .$node->title."\n"
			   .$node->og_description."\n\n";

	if ($node->og_selective == 2) {
		$message .= "This is an invite only group.\n\n";
	} elseif ($node->og_selective == 1) {
		$message .= "This is a moderated group where membership requests require admin approval.\n\n";
	} elseif ($node->og_selective == 0) {
		$message .= "This is an open membership group.\n\n";
	}


	if (variable_get('og_user_roles_assign_regcode_gid', 0) == 1) { // regcodes option on
	  if (variable_get('og_user_roles_assign_regcode_'.$gid, 0) == 1) { // regcodes for this group on
		$regcodes = variable_get('og_user_roles_regcode_value_'.$gid, 0);
		if ($regcodes != 0) { // regcodes for this group specified
			if (preg_match('/,/', $regcodes)) {
				// multiple regcodes
				$regcode = "<ENTER CODE HERE>";
				$notice = "<div class='invite_notice'>Don't forget to include the registration code.<br></div>"
						 ."<p><b>Available registration codes: ".$regcodes."</b></p>";
			} else {
				$regcode = $regcodes;
			}
		} else {
			// no regcodes
			$notice = "<div class='invite_notice'>No registration codes set up - edit your group homepage and enter some.</div>";
		}
		$message .= "To join the group by entering a registration code, use the following link:\n".
					"http://portal.transformationteam.net/og/regcode\n\n".
					"And enter the following code: ".$regcode."\n\n";
		
	  } else {
		// regcodes disabled for this group
		if ($node->og_selective == 2) {
			// invite only group
			$notice = "<div class='invite_notice'>"
					 ."Your group is <i>invite only</i> and you have not enabled registration codes.<br>" 			
					 ."NOBODY WILL BE ABLE TO JOIN!<br/>"
					 ."Edit your group homepage, and enable registration codes.</div>";
		}
	  }
	}
	
	$message .= "--\nInvite sent by ".$user->name." from the group '".$node->title."' at the Transformation Team.";
	
	$form['pmessage'] = array(
		'#type' => 'textarea', 
		'#title' => t('Personal message'), 
		'#description' => t('Optional. Enter a message which will become part of the invitation email.').$notice,
		'#default_value' => $message,
		'#rows' => 15,
		);
		
  }
	
somebodysysop’s picture

Status: Active » Postponed (maintainer needs more info)

When OGR 3.2 is released, if you're still interested in this, I suggest you submit a patch for that release.

mr.andrey’s picture

Version: 5.x-3.1 » 5.x-3.2

Sure, here's what I use now.

Insert this into your _form_alter script in template.php:
note: we do not use the "closed" group option at all - modify this to your own needs.

  if ($form_id == 'og_invite_form') {
    $gid = $form['gid']['#value'];
	$node = node_load($gid);
	global $user;
		
	// MESSAGE
	$message = "Hey there member,\n\n"
			   ."This is an invitation to join the group '".$node->title."'\n\n"
			   ."Please see the link and message below.\n\n"
			   .$node->title."\n"
			   .$node->og_description."\n\n";
	
	// GROUP TYPE
	if ($node->og_selective == 2) {
		$message .= "This is an invite only group.\n\n";
	} elseif ($node->og_selective == 1) {
		$message .= "This is a moderated group where membership requests require admin approval.\n\n"
				   ."You can request membership by following this link:\n"
				   ."http://site.net/og/subscribe/".$gid."\n\n";
	} elseif ($node->og_selective == 0) {
		$message .= "This is an open membership group.\n\n"
				   ."You can join this group by following this link:\n"
				   ."http://site.net/og/subscribe/".$gid."\n\n";
	}

	// REG CODES - invite only & moderated
	if (variable_get('og_user_roles_assign_regcode_gid', 0) == 1 && $node->og_selective > 0) { // regcodes on and group not open
	  if (variable_get('og_user_roles_assign_regcode_'.$gid, 0) == 1) { // regcodes for this group enabled
		$regcodes = variable_get('og_user_roles_regcode_value_'.$gid, 0);
		if ($regcodes) { // regcodes for this group entered
			if (preg_match('/,/', $regcodes) && og_is_node_admin($node)) {
				// multiple regcodes and group admin -> manually enter codes, show available codes
				$regcode = "<ENTER CODE HERE>";
				$notice .= "<div class='invite_notice'>Don't forget to include the registration code.<br></div>";
				$notice .= "<p><b>Available registration codes: ".$regcodes."</b></p>";
			} else { // single regcode
				if (og_is_node_admin($node)) { // group admin -> enter the code automatically
					$regcode = $regcodes;
				} else { // not group admin -> ask to enter the code manually
					$regcode = "<ENTER CODE HERE>";
					$notice .= "<div class='invite_notice'>Don't forget to include the registration code.<br></div>";
				}
			}
		} else { // regcodes for this group not entered
			$notice .= "<div class='invite_notice'>No registration codes set up - edit your group homepage and enter some.</div>";
		}
		$message .= "To join the group by entering a registration code, use the following link:\n".
					"http://site.net/og/regcode\n\n".
					"And enter the following code: ".$regcode."\n\n";
	  } else { // regcodes for this group disabled
		if ($node->og_selective == 2) {	// invite only group -> give no-regcode warning
			$notice .= "<div class='invite_notice'>"
					 ."Your group is <i>invite only</i> and you have not enabled registration codes.<br>" 			
					 ."NOBODY WILL BE ABLE TO JOIN!<br/>"
					 ."Edit your group homepage, and enable registration codes.</div>";
		}
	  } // end group regcodes
	} // end regcodes
	
	// FOOTER
	$message .= "--\nInvite sent by ".$user->name." from the group '".$node->title."' at the Site Name.";
	
	// FORM
	$form['pmessage'] = array(
		'#type' => 'textarea', 
		'#title' => t('Personal message'), 
		'#description' => t('Optional. Enter a message which will become part of the invitation email.').$notice,
		'#default_value' => $message,
		'#rows' => 15,
		);
  }

Best,
Andrey.

somebodysysop’s picture

Thanks!

somebodysysop’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)
chaps2’s picture

Status: Closed (fixed) » Active

I've submitted a patch for og 6.x here http://drupal.org/node/282810#comment-1435332 that gets close to what mr.andrey was originally after. It works for moderated groups. The fact that you can't send invites from an invite-only group is a different issue...

I looked into using og_user_roles and registration codes but I think they address a broader requirement that is necessarily more cumbersome.

sun’s picture

Status: Active » Closed (won't fix)

After the rise of the rewritten OGUR 4.x for Drupal 6, in which many unrelated features of OGUR were removed, and nearing a release of Drupal 7, I'm closing down old issues.