Mys 1.3.x Adding Titles to Users in PMs (ex. Admin, Mod, etc)

Forum
Last Post
Threads / Messages

GeneticAlpha

Loving Mysidia!
Member
Joined
May 24, 2020
Messages
287
Points
18
Age
31
Location
Tennessee
Mysidian Dollar
13,377
So I was really wanting the ability to have my staff have "Admin" or "Mod" etc displayed in Private messages. For proof a member is a staff member, and not just a member claiming to be staff by having "- Lost Era Staff" or something in their message text. I wanted it to officially display in the PMs and after almost a whole day of struggling with different code, I finally got it to work and wanted to share.

So what this does is displays whatever you have in the database before the user's name in the PM. So where it says From: (Username here) it now says:

From:
Admin (Username here)
and inside it'll have a display bar under the "(user) sent you this PM" that lists what staff type they are.

First you want to a new column in users database called staffmail (or whatever you want to call it, but for simplicities sake I'll say staffmail since it's what I used)
and set it to VARCHAR 20 then submit. This is what you'll be changing for each individual use, manually inputting Admin, Mod, or whatever you want.

Next let's do the Message Inbox display. So open class_messagetablehelper.php and find the protected function getProfile($param){ section around line 35.
You're going to be replacing the return function with this:

$staffmail = $mysidia->db->select("users", array("staffmail"), "username ='{$param}'")->fetchColumn();
return new Comment("{$staffmail} <a href='profile/view/{$param}'>$nickname</a>");


My code looks like this:

protected function getProfile($param){
$mysidia = Registry::get("mysidia");
$nickname = $mysidia->db->select("users", array("nickname"), "username ='{$param}'")->fetchColumn();
$uid = $mysidia->db->select("users", array("uid"), "username ='{$param}'")->fetchColumn();

if($param == "SYSTEM") return $param;

$staffmail = $mysidia->db->select("users", array("staffmail"), "username ='{$param}'")->fetchColumn();
return new Comment("{$staffmail} <a href='profile/view/{$param}'>$nickname</a>");
}

That should take care of the Inbox view. Next is within the PM. So open class_privatemessage.php and around line 70 find public function getPostbar(){ section.
Add inside it above the PostHeader:

if($sender->staffmail == "Admin"){
$postHeader->add(new Comment("<p style='color: #000000; background-color: #4287f5;'>{$sender->staffmail}</p>"));
}


Mine looks like this:


public function getPostbar(){
if($this->mid == 0) return FALSE;
$sender = new Member($this->fromuser);
$sender->getprofile();
$this->postbar = new Table("postbar", "100%", FALSE);
$postHeader = new TRow;

if($sender->staffmail == "Admin"){
$postHeader->add(new Comment("<p style='color: #000000; background-color: #4287f5;'>{$sender->staffmail}</p>"));
}

$postHeader->add(new TCell("<b>Employee Since: </b><br>{$sender->membersince}<br>"));
$this->postbar->add($postHeader);
return $this->postbar;
}

and that's it :)

NOTE: I used uids and a nicknames for my user names and stuff so you need to leave that stuff out unless you add the nickname into your database. Uids should work though.
 

Attachments

  • staffpm.png
    staffpm.png
    1.7 MB · Views: 9
  • staffpm2.png
    staffpm2.png
    1.3 MB · Views: 9
Last edited:
Congrats, the mod looks nice. Is this for Mys v1.3.5 and earlier?

Note in future, you can try to use the code tag to wrap your PHP code. If you cant find it, click the triple dot and you will see the </> button which allows you to insert code.
:)
 
Congrats, the mod looks nice. Is this for Mys v1.3.5 and earlier?

Note in future, you can try to use the code tag to wrap your PHP code. If you cant find it, click the triple dot and you will see the </> button which allows you to insert code.
:)
I fixed the quoted text :D and I made it with v1.3.5 but I'm sure it'll work for older versions and even the v1.3.6.
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,274
Messages
33,115
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top