I'm building a webpage that uses three separate profile types, this is, the "Show on all user account registration forms" option is not ticked for any of the three. Also, I have configured the registration forms to show up as tabs, and have disabled the "plain" user registration (user/register). The tabs work like a charm, only the fields of each type show for the corresponding type. However, when I try to use the registration blocks, the three following notices appear:
Notice: Trying to get property of non-object in profile2_regpath_block_view() (line 40 of *******/sites/all/modules/profile2_regpath/profile2_regpath_blocks/profile2_regpath_blocks.module).
Notice: Trying to get property of non-object in profile2_regpath_build_block_form() (line 57 of *******/sites/all/modules/profile2_regpath/profile2_regpath_blocks/profile2_regpath_blocks.module).
Notice: Trying to get property of non-object in profile2_regpath_build_block_form() (line 59 of *******/sites/all/modules/profile2_regpath/profile2_regpath_blocks/profile2_regpath_blocks.module).
And no matter what registration block I use, it appends all of the fields by weight, as if the "Show on all user account registration forms" was checked on all three profile types. Of course, the problem doesn't arise when logged in, as the block returned is NULL.
Comments
Comment #1
Axagthoth commentedThe following two lines are from the function profile2_regpath_block_view($delta = '')
$profile_id = str_replace('p2rp_register_', '', $delta);
$profile_type = profile2_load($profile_id);
If someone could please explain to me what the first one is intended to do, I think I could then pinpoint and solve the issue. All the problematic lines appear after the second one, and have in common that they try to access fields of $profile_type. It is my assumption that something fails at the profile2_load call, since I have tried substituting the referenced values by hardcoded values and the problem disappears. Any help would be appreciated!
Comment #2
Axagthoth commentedOkay, sorry for the frequent updates but this is a pressing matter to me. The line
works just fine, retrieving the correct profile_id. However for some reason in the following line
the call to profile2_load always returns false. I'm currently looking at the code in profile2, but as long as I can't solve it:
Does someone know why the call to profile2_load returns false for correct (i.e. existing) profile id's? Has anybody else encountered the issue?
Also excuse my ignorance, but I'm not sure whether this should be in the profile2 issue queue or here.
Comment #3
grasmash commentedIt's possible that $profile_type is not being correctly cast as an integer.
Let's try this:
This may also be specific to your version of php. Can you please tell me which version you are using?
Comment #4
grasmash commentedAh, I found the issue. profile2_load() actually loads profile2 objects, NOT profile2_type objects. So, we can use entity_load() instead:
Pushed to latest dev.
Comment #5
Axagthoth commentedOk, so now $profile_type seems to be correctly set as this line works (the correct label is printed):
However, from the following function:
The notices said something about an "undefined property" being called at those lines, so I looked at the DB tables created by profile2, and guess what? The property is called "id" not "pid". So if you rewrite the function like this:
Problem solved! Maybe you should push taht change to dev too.
Also, I hope I'm not being too much of a pain in the *** ;) couldn't live without your module!
Comment #6
grasmash commentedSorry, I forgot to mention the change from pid to id. I did make that change in the commit. Glad it's working for you! Good luck.