XF 2.0 Creating an alert

AndyB

Well-known member
Hello,

I'm creating an add-on for XF2 that requires a custom alert.

The following code:

PHP:
$userId = 2;
$user = \XF::app()->find('XF:User', $userId);
$alertRepo = \XF::app()->repository('XF:UserAlert');
$alertRepo->alert($user, $user->user_id, $user->username, 'user', $user->user_id, 'upgrade_end');
Produces this:

1504901316832.png

I searched for the 'upgrade_end' in the PHP code, Templates and Phrases, but I can't find where this is defined.
 
Last edited:

AndyB

Well-known member
Got it!

The 'upgrade_end' is actually a template called 'alert_user_upgrade_end', so all I needed to do was create a new template to acheive the alert I want to display.
 

logixsol

New member
@AndyB
$alertRepo->alert($user, $user->user_id, $user->username, 'user', $user->user_id, 'upgrade_end');
Here i set the 'resource' in place of 'user' and 'testing' in place of 'upgrade_end',
Then create a new template alert_resource_testing but it not showing the alerts.

Could you please help me ?
 

AndyB

Well-known member
I ended up abandoning the creating of custom alerts. I opted to send an email instead.
 
Top