Hi all,
I'm having what seems to be a faily common problem with a directory site, I've not been able to find a sollution by searching so here we go.
I have problems linking existing nodes (directory entries) to new accounts. I'm using a combination of Content Profile, Profile (core), CCK and Rules to acheive what I want.
Drupal Core 6.16
Content Profile 6.x-1.0-beta4
Rules 6.x-1.1
Users are able to register for an account either by selecting an existing directory entry and claiming it, or just create an unlinked account.
I have a custom field in the registration form provided by the core Profile module which gets auto filled if an existing node is chosen.
When the user registers and their email address is confirmed, at first login I use a Rule to run some custom php code like this:
global $user;
profile_load_profile($user);
$targetnode = node_load($user->profile_business_link);
if($targetnode and $targetnode->type == "business_details" and $targetnode->uid == 1)
{
$targetnode->uid = $user->uid;
$targetnode->revision = '0';
node_save($targetnode);
}
This has the desired effect of automatically setting the node uid of the selected business listing to the new user uid.
However, while the business listing shows up on the user page as though the profile is linked to the user, the edit tab at the top is missing and if they try to edit the node by navigating to the page directly they get an access denied page.
I know the permissions are correct for the role because new users who do not select a business on signup are able to hapilly create profiles and edit them. They also get the correct edit tab at the top of the user page.
Has anyone else hit this stage and was able to resolve it? Do I need to do more than just change the uid on the target node to change ownership?
Any thoughts appreciated.