PDA

View Full Version : Userid in PHP-Module


BulliM
02-01-2019, 08:24 AM
I've extended user profile site with a PHP-Module, which includes a php file. In this file I need to compare two variables.
$vbulletin->userinfo['userid'];
$vbulletin->page['userid'];
First variable is userid from user, who visits the profile. Second is whos profile you watch.

In my script, second variable is empty. How can I get access to user profiles userid in my included PHP-Script?

--------------- Added 1549044317 at 1549044317 ---------------

Frustrating.

noypiscripter
02-03-2019, 04:09 AM
The userid of the profile being viewed is not available in the $vbulletin variable. Just extract and parse it from the current profile URL.

$url = $_SERVER['REQUEST_URI'];
preg_match('/\/.*\/([0-9]+)\-.*/', $url, $matches);
if (count($matches) > 1) {
echo 'Userid: ' . $matches[1];
}

BulliM
02-03-2019, 06:17 AM
The userid of the profile being viewed is not available in the $vbulletin variable. Just extract and parse it from the current profile URL.

$url = $_SERVER['REQUEST_URI'];
preg_match('/\/.*\/([0-9]+)\-.*/', $url, $matches);
if (count($matches) > 1) {
echo 'Userid: ' . $matches[1];
}

Nice solution.

Because profile userid is available in $vbulletin->scriptpath, my solution was:

$to = strpos($vbulletin->scriptpath,"-");
$pageuserid = substr($vbulletin->scriptpath,8,($to-8));


Kind of the same way, but also differently.

noypiscripter
02-03-2019, 05:14 PM
What does scriptpath return? Can you give an example?

BulliM
02-03-2019, 05:27 PM
What does scriptpath return? Can you give an example?

/member/123-username