Hi,

I'm modifying some templates in phpBB and I'd need to access the user id of authenticated user in Drupal from the phpBB code.

Is it possible? If so, what will be the variable to use within the phpBB code (templates) ?

Thanks,

juan

Comments

ColdSun’s picture

You could add a custom phpbb profile field named DrupalID. Within those settings you could potentially have the following:
Field identification: drupalid
Field type: numbers

Visability:
Display in user control panel: No
Display on registration screen: No
Display on viewtopic screen: Optional, if you want a "MemberID" or something else, then yes
Required field: No
Hide profile field: No

After that, it should just involve adding another sync (manually unless its incorporated into a future release { =) } to the module file where you populate the phpbb profile field with the value of accountid

I'm curious as to why you're interested in accessing the accountid from within phpbb. Not so much because I see no uses for it, but instead because the choices are really unlimited. Personally, on implementations of which I have done, I have used it to add notifcations, use drupal's privatemessage module and use imagecache profiles instead of being forced into having additional versions unique to phpbb.

Added:
Additionally, I suppose you could create a custom profile field and have it pre-populate with your accountid and then simply sync that to the phpbb custom profile field. This would prevent you from having to edit the module file. I suppose it comes down to if VB feels that this addition will have enough merit to warrant adding to the code long term.

Toxid’s picture

Thanks for this information. I want to use drupal user ids to link the user names from phpbb to the user profile in drupal, that way never user phpbb profile. I think double profiles would only confuse the users.

tobyp’s picture

I managed to achieve this just a few days ago! I must say, it did take a good 30 minutes for me to figure the files that needed to be edited, but after that, it was a breeze!

Basically, you have to edit the phpBB3 PHP Includes files, so that they point to the Drupal user profile, instead of the phpBB one. This can be achieved very easily. Firstly, install the Pathauto Drupal module. Make an auto alias for all user profiles, so that they go to http://yoursite.com/users/[username]. Then basically, in the phpBB PHP Includes files, make the user profiles direct to: http://yoursite.com/users/{USERNAME}.

In phpBB, {USERNAME} means the user's username. So when you add http://yoursite.com/users/{USERNAME}, it will direct to the Drupal profiles that you created with Pathauto. For example, my Drupal profile pages are http://mysite.com/users/admin, and phpBB will use the {USERNAME} tag to print the user's username. So in phpBB, if you change the profile URLs, they'll go to the same place.

It's pretty easy, but will require a bit of PHP knowledge. Mine is working seamlessly now, and only took about 5 minutes after I'd searched through the phpBB files. What you must remember is - These modifications would be made to phpBB itself, and not Drupal, seeing as you want phpBB profiles to go to Drupal ones. If you need any help, let me know, I'll try to help you out. :)

ColdSun’s picture

It should be noted while this solution does solve linking to a drupal profile, it misses out on a large amount of the benifits provided by syncing a drupal-id to a custom field for phpbb. Some of these benefits include things such as a foothold into implementing userpoints/activity/actions, or more simply being able to link to user avatars without having to have multiple images in various locations (in this case phpbb and drupal).

Toxid’s picture

Is it possible to do it the other way around? I'd like to access the phpbb user id from drupals template.

ColdSun’s picture

I would imagine it is, I would look into how the drupal module handles the displaying of PMs sent through the phpbb system.

fizk’s picture

Status: Active » Closed (fixed)