News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Modify post "last edit" by name

Started by MobileCS, September 18, 2023, 11:49:55 AM

Previous topic - Next topic

MobileCS

I'm using SMF 2.1.4

When a post is modified, and it's not being modified by the original poster, I would like the "last edit" name to show "Admin".

How would I go about doing this?

I was originally messing with Sources/Display.php, but only got this far ... I think I'm on the wrong track?

          // Is this user the message author?
if ( !empty($output['modified']['name']) && $message['id_member'] <> $user_info['id'] )
{
$output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], 'Admin');
}
else
{
$output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']);
}

Does the change perhaps need to be made to the database when the post is actually saved? Force the id_msg_modified to be the id of an admin?

If so, how would I go about doing that?

Kindred

Hmmm, there was a mid that did something like this


But probably display.Template Php

Not the source file, but the output/template file
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

MobileCS

#2
I checked out that template file again and it only had ~5 lines that outputs what comes from Sources/Display.php

With that said, I did solve the issue by making the changes below :

Sources/Display.php

// Is this user the message author?
$output['is_message_author'] = $message['id_member'] == $user_info['id'];

$poster_name = strtolower($message['poster_name']);
$modified_name = strtolower($message['modified_name']);

if ( !empty($output['modified']['name']) )
{
if ( $poster_name <> $modified_name )
{
$output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], 'Admin');
}
else
{
$output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']);
}
}

Kindred

Hardcoding text is not good process...
Additionally,  you don't have a check to confirm that the editor is actually an admin...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

MobileCS

Yeah, my code does not check if the editor is actually an admin. It only checks to see if the post was edited by anyone other than the original poster.

Also, I wasn't aware that the word "Admin" was in the language files, so I changed it from hardcoded to $txt['admin'].

Advertisement: