This section contains detailed articles elaborating on some of the common issues phpBB users encounter while using the product. Articles submitted by members of the community are checked for accuracy by the relevant phpBB Team. If you do not find the answer to your question here, we recommend looking through the Support Section as well as using the Site Wide Search.

Link To User Profiles With Username.

Description: Learn how to link to a specific user's profile using pre-existing variables

In Categories:

Link to this article: Select All
[url=]Knowledge Base - Link To User Profiles With Username.[/url]

In the past you may have noticed that there is no easy way to link to a user's profile without custom variables because you need to find the id for that user. Well what most people do not know is that there is already a variable defined for the exact purpose to instead of using the user id, you may just simply add the username. It is as simple as swapping the vars.

User ID method:

Code: Select all

UserName Method:

Code: Select all

Of course in the url you replace the domain with your personal one and replace user with the actual username or id.

Here is a good example of this actually being implimented:

Code: Select all

<!-- IF not S_IS_BOT and S_USER_LOGGED_IN -->

<strong><a href="{ROOT_PATH}/memberlist.php?mode=viewprofile&un={S_USERNAME}">{S_USERNAME}</a></strong>

<!-- ENDIF -->

In this particular example you are using the variable {ROOT_PATH} which will automatically fill in the path to the root of your forum. Another Variable you are using is {S_USERNAME} which is simply the username of the user who you are logged in as.

The great thing about this trick is that you are not adding anything. This way everything is already included so you dont have to have any extra code pass through the preproccessor.