x
 
Create New Page
 View Previous Changes    ( Last updated by Lisa Wess )

Segments In Member Templates

Changes are made at your own risk and are not guaranteed to work. Always make backups of the database and files prior to implementing hacks. Make a special backup of the file and/or template you are modifying so that you can roll back quickly.

Hacks are dangerous and can cause your site to stop working. They make later updates to ExpressionEngine more difficult; you should track your hacks for post-update re-implementation. 

Most hacks are unnecessary, please review the Development Documentation for information on expanding ExpressionEngine via Modules, Extensions, and Plugins.

Hacks are never officially supported.

Question:

Does the member registration form ignore url segments? I can’t get it to work. I’m trying to assign a value to a hidden field in the form based on {segment_3}, but it never seems to work. Or perhaps my lack of sleep is getting to me?

Answer:

The basic answer is yes, but it is a fairly simple hack to modify it.

-Go create 2 member groups: webloga and weblogb

-Figure out the group id for each group, say by going into Admin › Member Groups, where it will tell you the group id.

-Go to webloga, which has a group id of 12. Now, make the link for the registration form look like:

<a href="{path="member/register/group/12/"}">Register</a>

So you’re just passing the member group in segment_4

Now, go into Admin › Member Profile Templates › Default
Select the Registration Form. You’ll need to edit it to include the hidden field. Put it anywhere in the form- but if you need an example, just stick it above the:

<p><input type="submit" value="{lang:submit}" class="submit" /></p>

So now it looks like:

<input type="hidden" name="group_id" value="{segment_4}" />
<
p><input type="submit" value="{lang:submit}" class="submit" /></p>

Then you just need to go in and hack the backend so it does something with your hidden field.

Keep a copy of the original file, then open up /system/modules/mod.member.php

Now- I haven’t done this, but just copy/pasting Crusty’s directions:

Scroll down to line 3026 and added the following line below it:

$reg_form =& str_replace(LD.'segment_4'.RD, $IN->fetch_uri_segment(4), $reg_form);

Then: Around line 3230, replace:

$data['group_id'] = 4; // Pending

with the following code:

if (!empty($_POST['group_id']))
{
   
if ($_POST['group_id'] != 1)
$data['group_id'] = $_POST['group_id'];
else
$data['group_id'] = 4; // Pending

} else
{
    $data[
'group_id'] = 4; // Pending


}

You could also replace the line on 3240 with the same thing if you wanted.

No clue what changing line 3240 would do, but the code is well commented, so you could probably figure it out.

Note- I haven’t done it, but the directions look pretty straightforward.

Category:Hacks Category:Templates Category:Members

Categories: