Code to create link to user's phpBB profile

Post a reply


This question is a means of preventing automated form submissions by spambots.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

If you wish to attach one or more files enter the details below.

Maximum filesize per attachment: 1 MiB.

Expand view Topic review: Code to create link to user's phpBB profile

Re: Code to create link to user's phpBB profile

by teebling » Wed Jun 17, 2020 3:25 pm

axew3 wrote: Wed Jun 17, 2020 3:09 pm
So uhh... does this mean I can also pull say their avatar, signature and anything from that array?
Yes!
Awesome, thanks so much for your support.

Re: Code to create link to user's phpBB profile

by axew3 » Wed Jun 17, 2020 3:09 pm

So uhh... does this mean I can also pull say their avatar, signature and anything from that array?
Yes!

Re: Code to create link to user's phpBB profile

by teebling » Wed Jun 17, 2020 3:04 pm

Yes! That worked. Fantastic grazie mille :)

--------------------

For future users this is how I got it working:

In your Wordpress theme's (or child theme's) header file, at the very top of the file, before everything, add:

Code: Select all

<?php 
if (defined('W3PHPBBUSESSION')) {
   $phpbbUser = unserialize(W3PHPBBUSESSION);
  }  
  ?>
Then, where you want the link to the user's profile to be in the template, put:

Code: Select all

<a href="/memberlist.php?mode=viewprofile&u=<?php echo $phpbbUser[0]->user_id; ?>">My forum profile</a>
Make sure the URL path to your forum is correct ^

--------------------

So uhh... does this mean I can also pull say their avatar, signature and anything from that array?

Re: Code to create link to user's phpBB profile

by axew3 » Wed Jun 17, 2020 2:52 pm

Where you are adding the code?

You need to put this just before the call to var or vars you want, so add

Code: Select all

<?php 
if (defined('W3PHPBBUSESSION')) {
   $phpbbUser = unserialize(W3PHPBBUSESSION);
  }  
  ?>
now $phpbbUser contain all data, then
the phpBB user ID will be $phpbbUser[0]->user_id

you can do like this:

Code: Select all

<a href="https://www.axew3.com/w3/forums/memberlist.php?mode=viewprofile&u=<?php echo $phpbbUser[0]->user_id; ?>">My forum profile</a>
OR like this:

Code: Select all

echo '<a href="https://www.axew3.com/w3/forums/memberlist.php?mode=viewprofile&u='.$phpbbUser[0]->user_id.'">My forum profile</a>';

Re: Code to create link to user's phpBB profile

by teebling » Wed Jun 17, 2020 2:47 pm

Update - I actually managed to get all of the data from the phpBB database to print:


(Attachment removed for privacy).


Only problem is that it prints EVERYTHING and not just the user_id :?

How do I, in the anchor tag, just print the user_id value?

Re: Code to create link to user's phpBB profile

by teebling » Wed Jun 17, 2020 2:35 pm

Hey axe, thanks for getting back to me.

I tried the following but it did not work...

In one of my wordpress template files at the top I put:

Code: Select all

<?php
if (defined('W3PHPBBUSESSION')) {
   $us = unserialize(W3PHPBBUSESSION);
   print_r($us); exit;
  } 
?>
In the same template file, further down, I used the link:

Code: Select all

<a class="menulink" href="/memberlist.php?mode=viewprofile&u=<?php echo $us[0]->user_id; ?>" title="View your profile" role="menuitem">
But this doesn't work - in the URL there is no number printed at the end of &u= so it doesn't seem to pull the user ID.

Is there anything I'm missing here in terms of code?

Top