Profile linking


I have a script setup, where whenever somebody writes a persons username, it automatically links them to there profile.

For example.

Hi John, How are you.

But if john changes his username, the change won’t be reflected in that post. How can it update in the post?

I presume that you are the programmer of the script which enables/adds the link to the profile automatically.
I think the link should not be changed at all if you have used the ID of the user in the link to the profile page. But if you want to change the username in all the posts, then simply replace all the occurrences of the older username in the posts to new one when you update the username.

Is it that simple? :slight_smile:

Hi, This would not be possible because say I have 1000 posts containing the username John. If john changes his username, it would have to update all 1000 posts. This could possible crash my database.

Where and how many times is the link auto-linked to “John” at the moment?

You are not doing the auto-linking translation on the fly?


I am just speaking hypothetically. It wouldn’t be very healthy to update the posts every time John changes his username. Is there any other solution?

Seemingly you want to replace text which contains:

a) “It was user #person1234 wot said it”


b) “It was user <a href=/users/1234>John</a> wot said it”

Am I right?

Well if

a) lives in your database (what you may call the “dynamic” copy), and
b) is created and cached as a text file that will deal with one-time “translations” (what you may call the cached copy)

The TTL (Time To Live) for your cache could be 5 minutes, 1 hour, 1 day - or could be forever or until some action triggers a rewrite of all you cache.

This is how I do it.

Much will depend on you insert #person1234 into the text flow, do they pick from a list? or are you in fact storing b) in your database from the get go?

You can also send a) to the client and have JS do that rewrite on the fly. It does work but I would not really recommend it.