Userid from Username and redirect

A multipurpose module, plugin and component

Userid from Username and redirect

New postby jtporsche » Mon Jan 31, 2011 4:27 am

I need to integrate with a non-Joomla application hosted on a different server. What I'm trying to do is allow a user from that application to click a username to see that user's profile within Joomla. The application has access and can send along the username (but not the userid).

I'm trying to use Jumi to receive the "request" from the other application, get the username from the query string, do a db lookup to get the userid from the username, and then redirect the user to the normal view profile page with the userid as a new querystring.

Here's the php code I've tried using so far, but I'm getting an error that I think means I can't use the $_GET syntax. Is there some other way to read the querystring value?

And if anyone has any suggestions on how to redirect to the profile page without making the user click a link that'd be great : )

Code: Select all
defined('_JEXEC') OR defined('_VALID_MOS') OR die( "Direct Access Is Not Allowed" );

// Grab the user name from the querystring
$user = $_GET["user"];

//DB lookup to get userid from username string
$db =& JFactory::getDBO();
$query = "
  SELECT ".$db->nameQuote('id')."
    FROM ".$db->nameQuote('#__users')."
    WHERE ".$db->nameQuote('username')." = ".$db->quote($suser).";
$result = $db->loadResult();

Echo "Test: $result";
Posts: 1
Joined: Mon Jan 31, 2011 4:19 am

Return to Jumi

Who is online

Users browsing this forum: No registered users and 4 guests