Unofficial SMF API Documentation

The online log

who_allowed

call_integration_hook('who_allowed', array(&$allowedActions)
Type Parameter Description
array &$allowedActions Hashmap of actions that require specific permissions
Called from
determineActions() in ./Sources/Who.php
Notes
Since 2.1
The example below will use $txt['whoallow_mynewaction'] if the current user has either mypermission or mysecondpermission.
In this case, the current user is the one viewing the online log, not the one who’s log is being viewed.

Example usage

function my_who_allowed(&$allowedActions)
{
	$allowedActions['mynewaction'] = ['mypermission', 'mysecondpermission'];
}

integrate_whos_online

call_integration_hook('integrate_whos_online', array($actions)
Type Parameter Description
array $actions Hashmap of request components ($_GET)
Called from
determineActions() in ./Sources/Who.php
Notes
Since 1.1
index.php?action=page;sa=something results in $actions being array(‘action’ => ‘page’, ‘sa’ => ‘something’)`
This is one of a select few hooks where you must return data instead of modifying a parameter.
The parameter is passed by value, not by reference. This means that any modifications to it will not be seen outside of your function!

Example usage

function my_whos_online($actions)
{
	if (isset($actions['action']) && $actions['action'] === 'mynewaction' && allowedTo(['mypermission', 'mysecondpermission']))
		return 'stuff'; // NOT a $txt key!
}

Example usage (New syntax introduced in 2.1 RC3)

function my_whos_online($actions)
{
	return array(
		'label' => 'my_who_txt_var', // Required
		'class' => 'my_css_class', // Optional; skips the HTML attribute if left empty
		'tag' => 'my_html_tag' // Optional; default tag name is span
	);
}

whos_online_after

call_integration_hook('whos_online_after', array(&$urls, &$data)
Type Parameter Description
array &$urls Hashmap of request components where keys are session identifiers generated by PHP (may be an IP address for as guest)
array &$data Hashmap of session data for the template
Called from
determineActions() in ./Sources/Who.php
Notes
Since 2.1
Each element of &$urls has the following definition:
Type Key Description
string 0 JSON encoded raw request data
string 1 The member id
Each element of $data can be either a string or an array with the following definition:
Type Key Description
string label Required; a $txt var
string class Optional; skips the HTML attribute if left empty
string tag Optional; default tag name is span

Example usage

function my_whos_online_after(&$urls, &$data)
{
	foreach ($urls as $k => $url)
	{
		// Get the request parameters..
		$actions = json_decode($url[0], true);
		if ($actions === null)
			continue;

		// Only our actions
		if (isset($actions['action']) && $actions['action'] === 'mynewaction' && allowedTo(['mypermission', 'mysecondpermission']))
		{
			$data[$k] = [
				'label' => 'my_who_txt_var', // Required
				'class' => 'my_css_class', // Optional; skips the HTML attribute if left empty
				'tag' => 'my_html_tag' // Optional; default tag name is span
			];
			if (isset($actions['sa']))
			{
				if ($actions['sa'] == 'mynewsubaction' && allowedTo('mypermission'))
					$data[$k] = 'stuff';
				if ($actions['sa'] == 'mysecondsubaction' && allowedTo('mysecondpermission'))
					$data[$k] = 'thing';
			}
		}
	}
}

Suggest an edit to this page on GitHub