If you enable a path prefix for a multilingual site for example:

en/myprofile/register

the $path_key in the function profile2_regpath_form_alter is 'en' instead of 'myprofile' so the fields are not loaded in the registration.

Comments

rollingnet’s picture

I can confirm this bug.
We are developing a multilingual site (en/it) and if we look at registration form without language prefix, everything is ok
http://dev.siuro.it/socio/register

but if we use language prefix path, the profile fields disappear
http://dev.siuro.it/en/socio/register

rollingnet’s picture

I think this is a serious issue for this module, since many sites are multi language.
I'm not so expert to correct this issue by myself, could someone fix it?

rollingnet’s picture

I don't know using Git, so I publish the patch here

in profile2_regpath.module, after line #178 of 7.2.x-dev, insert this code

$path_parts = explode('/', $path);
+      if($form['locale']['language']['#default_value'] == $path_parts[0]) {
+        unset($path_parts[0]);
+        $path_parts = array_values($path_parts);
+      }
$path_key = reset($path_parts);
rodrigoaguilera’s picture

StatusFileSize
new576 bytes

here is the patch (it was line 178 against 2.x-dev)

rollingnet’s picture

Status: Active » Needs review
c4antonio’s picture

perfect, you resolve my worst nightmare of the last 48 hours, thank you :D

rollingnet’s picture

Status: Needs review » Patch (to be ported)
rodrigoaguilera’s picture

To be ported to...?
If you think the patch is ok you should use Reviewed &... (RTBC)

nevergone’s picture

Status: Patch (to be ported) » Reviewed & tested by the community

#4 patch tested and works well!

markus_petrux’s picture

Priority: Normal » Critical
markus_petrux’s picture

BTW, the patch is also needed for (and applies with just an offset to) 7.x-1.x-dev.

markus_petrux’s picture

grasmash’s picture

Status: Reviewed & tested by the community » Needs review

You need to first check that $form['locale'] is set, given that some sites may not have the locale module enabled.

grasmash’s picture

Status: Needs review » Needs work
tim_dj’s picture

now with check for form['locale']

Stolkmachine’s picture

Consider this:

$form['locale']['language']['#default_value'] = "en-US".

Now consider the prefix would be: "en". The code will fail in this scenario.

I would suggest a few things:

1) check if core module locale is enabled
2) use global language object prefix

tim_dj’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
dzy’s picture

shi99’s picture

Status: Needs work » Needs review
StatusFileSize
new716 bytes

I think the patch above will only work for profiles that are set as a Separate environment

On the edit Profile admin page there is the option for setting the "Registration page type".
The options are : Tabs and Separate environments which generate different paths
Tabs:
www.example.com/en/user/[PROFILE_TYPE]/register

Separate environments:
www.example.com/en/[PROFILE_TYPE]/register

So Separate environments will return "[PROFILE_TYPE]" but Tabs will return "user".

Instead of starting from the start of the path, would it be better to get the second last item from the path?

end($path_parts);
$path_key = prev($path_parts);

I have created a patch that works for me.

Thanks

Status: Needs review » Needs work

The last submitted patch, 21: profile2_regpath_path_key-2243511-21.patch, failed testing.

alex.bukach’s picture

Status: Needs work » Fixed

7.x-2.0-beta4 has a fix for the issue very similar to the proposed in #21:

$path = explode('/', str_replace('/register', '', $url['path']));
$path_key = end($path);

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

alex.bukach’s picture

StatusFileSize
new1.05 KB

Actually I was wrong, the issue persists in 7.x-2.x. However the proposed solution #21 does not work for me when using an alias. Here's an updated patch. Please change the issue status to Needs review.