I am helping a small org get through a membership renewal campaign again this year that has organizational memberships. A report from a user about an error sent me looking to understand what was happening.
To test, I created some fake users and gave them employers as well. So in each case there is an individual and related organizational contact. I have a contribution page that is set to "on behalf of". The page loads. It can be completed and submitted. However when entered with a URL like "https://sitename.org/civicrm/contribute/transact/?reset=1&id=21&cs=c7796dee0e6d34a976aa8a8a7ea7c25b_1702432880_168&cid=33557", the header shows the contact's name, the regular name and email profile at the bottom of the page is filled, but the "on behalf of" reserved profile is blank. I swear this worked last year.
I tested this for multiple users with the same result. Interestingly, when I test for my own user, I get the "Membership Organization" values in the "on behalf of" profile. That is, it shows the org I am joining as a member, not the one I "work for". Not really what is intended.
I also tested another site and got the same result of blank "on behalf of" profiles. If I had not used this in previous years I would just assume this function doesn't work, but I'm sure this worked last year.
I'm hoping someone can shed light on this situation or offer thoughts for troubleshooting. Unfortunately, the situation has become somewhat urgent as I didn't catch this before the mailing went out. We'll need to follow up, but I would really like to have something useful to say.
There are no entries of any kind in the Civi or Apache error logs. I'm running 5.68.0 on WordPress 6.4.2 and PHP 8.2.13
UPDATE: Expanding my test set reveals a couple of older contacts where it works. However, looking at their relationships tab and employer field reveal that these contacts don't show their employer relationship on the relationships page. If I try to add it, I get a duplicate error. If I remove their employer, I can add them on the relationships page. However, the employer field does not visibly populate on the summary tab. If I click in to edit, it shows it filled after all, but when I click save to get out to view, it vanishes. Further, once I have removed and re-added the employer/employee relationship in this manner the "on behalf of" form is blank for this contact now too.
I'm wondering if some sort of relationship bug may have been introduced as the interface has started to incorporate SearchKit and FormBuilder interface elements? I am absolutely baffled.
UPDATE 2: @petednz got me started with the answer to my main question, but as I tried to work through that correction, a deeper problem that I had hinted at up above came into full view. I am having a new and serious problem with relationship handling. I will post a new question about that.