Difference between revisions of "OnAfterBanningUser"

(Example)
(Example)
 
Line 5: Line 5:
 
An array of two items; user id who performed the banning action and the user id which is banned.
 
An array of two items; user id who performed the banning action and the user id which is banned.
  
===Example===
+
==Example==
 
<syntaxhighlight lang="php">
 
<syntaxhighlight lang="php">
 
/**
 
/**
Line 11: Line 11:
 
* @param $userId user id who has been banned
 
* @param $userId user id who has been banned
 
*/
 
*/
public function OnAfterBanningUser($adminId, $userId)  
+
public function onAfterBanningUser($adminId, $userId)  
 
{
 
{
 
//do any operation that you need here with the $adminid and $userid
 
//do any operation that you need here with the $adminid and $userid
 +
}
 +
</syntaxhighlight>
 +
<br />
 +
 +
==Add Notification to Queue Example==
 +
<syntaxhighlight lang="php">
 +
public function onAfterBanningUser($adminId, $userId)
 +
{
 +
$cmd = 'system_messaging'; // type of notification
 +
$actor = $adminId; // our admin who performed the action will be the "actor"
 +
$target = '965'; // target should be whoever is receiving the notification
 +
$subject = "Administrator ".$adminId->getDisplayName()." just banned the user ".$userId->getDisplayName().""; // Subject of both, email and popup notifications
 +
$body = 'This is the notification body message'; //Body message in emails.
 +
$template = ''; // If you need to use specific jomsocial template file, you can define it here. Leave it empty to use default system messaging template.
 +
$params = new CParameter(''); // We want to create an additional params object, and assign data to it, without having to formally define a class
 +
 +
CNotificationLibrary::add( $cmd , $actor , $target , $subject , $body , $template , $params );
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 
<br />
 
<br />

Latest revision as of 03:43, 5 July 2016

Description

This event will be triggered when the user is banned.

Params

An array of two items; user id who performed the banning action and the user id which is banned.

Example

/**
	* @param $adminId admin id who banned the user
	* @param $userId user id who has been banned
	*/
	public function onAfterBanningUser($adminId, $userId) 
	{
		//do any operation that you need here with the $adminid and $userid
	}


Add Notification to Queue Example

public function onAfterBanningUser($adminId, $userId) 
	{
		$cmd = 'system_messaging'; // type of notification
		$actor = $adminId; // our admin who performed the action will be the "actor"
		$target = '965'; // target should be whoever is receiving the notification
		$subject = "Administrator ".$adminId->getDisplayName()." just banned the user ".$userId->getDisplayName().""; // Subject of both, email and popup notifications
		$body = 'This is the notification body message'; //Body message in emails.
		$template = ''; // If you need to use specific jomsocial template file, you can define it here. Leave it empty to use default system messaging template.
		$params = new CParameter(''); // We want to create an additional params object, and assign data to it, without having to formally define a class
 
		CNotificationLibrary::add( $cmd , $actor , $target , $subject , $body , $template , $params );
	}