Found a small issue with my selected role not being assigned after uploading a file on the registration form (I have an image field on the registration form which is attached to the user and not the profile).

On line 377 of profile2_regpath.module, $profile_types will only be retrieved from the $_SESSION['p2rp_profile_types'] array if arg(0) == 'system', but for me arg(0) is equal to 'file' (arg(1) is still 'ajax').

My quick fix was to look for both:
if (!$profile_types && in_array(arg(0), array('system', 'file')) && arg(1) == 'ajax' && isset($_SESSION['p2rp_profile_types']))

fwiw. I noticed the dev version also looks for 'system/ajax' on line 487.

Comments

grasmash’s picture

Status: Active » Fixed

Thanks for pointing this out, I hadn't realize that ajax file uploads use a different system path.

I've made a fix for this in 7.x-1.x-dev based on your suggestion.

Status: Fixed » Closed (fixed)

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

2pha’s picture

Version: 7.x-1.6 » 7.x-1.11
Status: Closed (fixed) » Needs review

Is this still an issue?.
I had this module working fine until I added an image upload to the profile, now the role does not get assigned. (Image field is assigned to the profile, not the user form)
I am using 7.x-1.11
I am also using field groups if that makes a difference.

2pha’s picture

I changed

if (empty($form_state['profiles'][$type_name])) {

to

if (empty($form_state['profiles'][$type_name]) || !array_key_exists($key, $form['account']['roles'])) {

And all seems ok, though there probably needs to be some more "if" logic within this "if" so unnecessary processing is not done

jdanthinne’s picture

Status: Needs review » Reviewed & tested by the community

#4 Working for me.

grasmash’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the info.

I've believe that I've fixed the bug, although I did not use your snippet.

Please check the latest dev version and let me know if you experience any problems.

2pha’s picture

Tested 7.x-1.x and it seems to work well.

After looking at your commit comments I had to look up the word "kruft"...it gave me a laugh, and taught me a new word :)

grasmash’s picture

Hah,

I actually meant to write "cruft," but Urban Dictionary's definition of "kruft" could apply in some metaphorical sense.

Status: Fixed » Closed (fixed)

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