Author Topic: User profile link? USERID instead of USERNAME  (Read 9284 times)

0 Members and 1 Guest are viewing this topic.

Offline DiGiMetiN

  • Newbie
  • *
  • Posts: 42
    • View Profile
User profile link? USERID instead of USERNAME
« on: May 07, 2005, 04:47:10 PM »
member.php?action=showprofile&user_id=1

instead of

member.php?action=showprofile&who=DiGiMetiN

What is code?
Nette'ki Dahi'lerden...

Offline DiGiMetiN

  • Newbie
  • *
  • Posts: 42
    • View Profile
Re: User profile link? USERID instead of USERNAME
« Reply #1 on: May 10, 2005, 11:47:01 PM »
Please help me!  :(
Nette'ki Dahi'lerden...

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Re: User profile link? USERID instead of USERNAME
« Reply #2 on: May 11, 2005, 12:55:38 AM »
user_id=1

instead of

who=DiGiMetiN

I do not understand, user_id IS the way 4images works.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: User profile link? USERID instead of USERNAME
« Reply #3 on: May 11, 2005, 01:23:43 AM »
I do not understand, user_id IS the way 4images works.
I belive they want the opposite ;)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline universal

  • Full Member
  • ***
  • Posts: 213
    • View Profile
    • http://www.funny.lt
Re: User profile link? USERID instead of USERNAME
« Reply #4 on: May 14, 2005, 06:35:17 PM »
Did you mean something like that?
Demo: http://www.pramoga.net/who/admin/
Again this addres?!
http://www.funny.lt


Offline universal

  • Full Member
  • ***
  • Posts: 213
    • View Profile
    • http://www.funny.lt
Re: User profile link? USERID instead of USERNAME
« Reply #6 on: May 15, 2005, 07:32:48 AM »
Just try to edit the code below this, I don`t want to edit for my site (as I have only one copy and it`s in public :lol: ):
Code: [Select]
//-----------------------------------------------------
//--- Show Profile ------------------------------------
//-----------------------------------------------------
if ($action == "showprofile") {

Btw this not the only code I think, that is needed to change...

Good luck ;)
Again this addres?!
http://www.funny.lt

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: User profile link? USERID instead of USERNAME
« Reply #7 on: May 15, 2005, 08:15:54 AM »
before the hack I've posted the code for this...unfortunetly it was lost...

I'll try to restore it, but I must warn, I will not test it, so use it on your own risk:

Step 1
In member.php find:
Code: [Select]
if ($action == "showprofile") {Insert below:
Code: [Select]
  if (isset($HTTP_GET_VARS['user_name']) || isset($HTTP_POST_VARS['user_name'])) {
    $user_name = (isset($HTTP_POST_VARS['user_name'])) ? $HTTP_POST_VARS['user_name'] : $HTTP_GET_VARS['user_name'];
  }
  else {
    $user_name = "";
  }

Step 1.2
A few lines below find:
Code: [Select]
  if ($user_row = get_user_info($user_id)) {(make sure its in the "showprofile" section!)
Replace it with:
Code: [Select]
  if ($user_row = get_user_info($user_id, $user_name)) {

Step 2
In includes/functions.php find:
Code: [Select]
function get_user_info($user_id = 0) {
  global $site_db, $user_table_fields;
  $user_info = 0;
  if ($user_id != 0 && $user_id != GUEST) {
    $sql = "SELECT *
            FROM ".USERS_TABLE."
            WHERE ".get_user_table_field("", "user_id")." = $user_id";
Replace it with:
Code: [Select]
function get_user_info($user_id = 0, $user_name = "") {
  global $site_db, $user_table_fields;
  $user_info = 0;
  if (($user_id != 0 && $user_id != GUEST) || $user_name) {
    $sql = "SELECT *
            FROM ".USERS_TABLE."
            WHERE ".(($user_name) ? get_user_table_field("", "user_name")." LIKE '".addslashes($user_name)."'" : get_user_table_field("", "user_id")." = $user_id");

From there you can use urls like: member.php?action=showprofile&user_name=admin

Now is the tricky part to adopt the already existing code to create such urls.
because there are many places which conteins urls to view members profiles, I'll only explain what needs to be changed

In the files where links to members profiles are being created (functions.php - for image owners, details.php - comment owners, memberlist.php - list of members, etc)
search for:
showprofile
then in the same line u should see something like this:
Quote
ROOT_PATH."member.php?action=showprofile&".URL_USER_ID."=".$image_row['user_id']
the part in red will be replaced by word user_id in the url, so u need replace it with user_name
the part in green will be replaced by the user id (number), u need replace with $image_row['user_name']
so, the end result should looks like:
Quote
ROOT_PATH."member.php?action=showprofile&user_name=".$image_row['user_name']
(btw, this example was taken from includes/functions.php ;))

But dont get too existed, it might not work just like that, without modifying other parts of code and in each case it might be different.

For example, in details.php the url part looks different:
Quote
ROOT_PATH."member.php?action=showprofile&".URL_USER_ID."=".$comment_user_id
As u can see, the part in green color is different, but fortunetly it will work without any extra modifications by replacing the code in red the same way as discribed in previous example and part in green with $comment_user_name (that's just luck!)
So, in this example the end result should looks like this:
Quote
ROOT_PATH."member.php?action=showprofile&user_name=".$comment_user_name

In some cases (mostly in the mods) there parts in red might looks simple as user_id (lowercase and without quotes), dont panic, just replace it with user_name



Confused enough yet?

Good luck.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline DiGiMetiN

  • Newbie
  • *
  • Posts: 42
    • View Profile
Re: User profile link? USERID instead of USERNAME
« Reply #8 on: May 15, 2005, 12:40:53 PM »
very very thanks V@no.

Now working.

Best Regards
Nette'ki Dahi'lerden...

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Re: User profile link? USERID instead of USERNAME
« Reply #9 on: May 16, 2005, 01:45:33 AM »
Here's another mod that shortens the URL considerably:
http://www.4homepages.de/forum/index.php?topic=7938.0