XF 2.2 How to show custom user in alert

FoxSecrets

Active member
I have a custom table with more user information and I need to show his name from this table in alert, but have no idea how.

Currently the alert calls his username from XF user table. How to change this $user? Where does it come from?

Code:
{{ phrase('x_has_alerted_you', {
    'user': username_link($user, false, {'defaultname': $fallbackName})
}) }}

Code:
        $alertRepo->alert(
            $this->purchase->Receiver,
            $this->purchase->Sender->user_id,
            $this->purchase->Sender->username,
            'user',
            $this->purchase->Receiver->user_id,
            $alertType,
            []
        );
 
Last edited:
I found out that I can pass extra data to alert, but how to read it? I tried but didn't work.

Code:
        $alertRepo->alert(
            $this->purchase->Receiver,
            $this->purchase->Sender->user_id,
            $this->purchase->Sender->username,
            'user',
            $this->purchase->Receiver->user_id,
            $alertType,
            ['name' => $profile->name]
        );

Template:
Code:
{{ phrase('user_alert_sender', {
    'name': $name
}) }}
 
I found out that I can pass extra data to alert, but how to read it? I tried but didn't work.

Code:
        $alertRepo->alert(
            $this->purchase->Receiver,
            $this->purchase->Sender->user_id,
            $this->purchase->Sender->username,
            'user',
            $this->purchase->Receiver->user_id,
            $alertType,
            ['name' => $profile->name]
        );

Template:
Code:
{{ phrase('user_alert_sender', {
    'name': $name
}) }}
$extra.name
 
Back
Top Bottom