Mys 1.3.5 Last Login Mod

Forum
Last Post
Threads / Messages

GeneticAlpha

Loving Mysidia!
Member
Joined
May 24, 2020
Messages
288
Points
28
Age
32
Location
Tennessee
Mysidian Dollar
13,392
So, I'm not really sure where my database column 'lastlogin' came from lol but me and my friend had one and neither of us could remember, nor was it functional that we could tell, and I was frustrated because I was really wanting a "Last Worked: (date here)" on my user profiles. So I figured out how to get it to work! So, if you want a Last Active or a thing for a date to be shown somewhere that updates each day, this is what I got working.
(If this lastlogin was part of a mod we don't remember, and you have that mod, just change lastlogin to whatever you want and change the rest of the code with lastlogin to that new name)

Onwards! Let's do database stuff first.
Go to your users_profile table, then to Structure, and add a new column:

lastlogin | VARCHAR | 25 | Default: Define as ?

enter.

Go to class_userprofile.php and add this above your bio info:

$date = new DateTime;

$mysidia->db->update("users_profile", array("lastlogin" => $date->format("m-d-Y")), "uid = '{$mysidia->user->uid}'");

$lastlogin = $mysidia->db->select("users_profile", array("lastlogin"), "username = '{$mysidia->input->get("user")}'")->fetchColumn();​

Then in the bio, this:
<br>Last worked: {$lastlogin}​


And that's it! :) You can change the m-d-Y area to display how you want, just make sure the year is capital Y. I like it to display month first, then day, then year. But apparently default is: year, day, month, and my brain doesn't like that lol.
 

Attachments

  • login.png
    login.png
    1.3 MB · Views: 9
Last edited:
Okay, I'm trying this for 1.3.6, but there's been a snag. I tried just as written in "model/domainmodel/userprofile.php", but that didn't work.

So, when I was digging around, I found the function "getLastActivity()" in model/domainmodel/users.php"
PHP:
public function getLastActivity(){
        return $this->lastActivity;
    }

I tried to use this in the "userprofile.php":
PHP:
public function getBio(){
        $date = new DateTime;
        $lastlogin = $this->getLastActivity();
      
        $document->add(new Comment("Last Online: {$lastlogin}"));
        return stripslashes($this->bio);
    }
but this doesn't work either. Any ideas?
(I have "lastlogin" on my "users_profile" database, but I don't know how to change it to the date the person logged in or how to call it to put it on the bio.)
 
Update:
I have managed to get the last login to show, but I don't know how to update it when they get online.

I changed the "protected function displayAboutme()" in "model\viewmodel\userprofileviewmodel.php" to this:
PHP:
protected function displayAboutme(){
        $mysidia = Registry::get("mysidia");   
        $division  = new Division;
        $title = new Comment($mysidia->lang->basic . $this->model->getUser()->getUsername());
        $title->setBold(TRUE);
        $title->setUnderlined(TRUE);   
        $basicinfo = "<br><strong>Member Since:</strong> {$this->model->getUser()->getMemberSince('Y-m-d')}<br>
                    <strong>Last Online:</strong> {$this->model->getLastLogin()} <br>
                    Gender: {$this->getModel()->getGender()}<br>
                    Favorite Color: {$this->model->getColor()}<br>
                    Nickname: {$this->model->getNickname()}<br>
                    Bio: {$this->getBio()}";
      
        $division->add($title);
        $division->add(new Image($this->model->getAvatar(), "avatar", 100));
        $division->add(new Comment($basicinfo));
        return $division;
    }

And I added this:
PHP:
public function getLastLogin(){
        return $this->lastlogin;
    }
to "model\domainmodel\userprofile.php" to get it to show up (you still have to add a "lastlogin" column to "adopts_users_profile", so don't forget that!!!!)

But I'm at a loss on how to update it only when that specific person logs in. I'm going to keep playing with it, but if someone figures it out, please let me know!!
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,306
Messages
33,297
Members
1,611
Latest member
razorbladekitty
BETA

Latest Threads

Top