lognote (function)

Last updated: Mon, Apr 17, 2023 12:51 pm
Return to Knowledgebase

Purpose

Allows you to customize the content of the admin logs.

Location

users/helpers/us_helpers.php

Parameters

# Parameter Data Type Required Description
1 $logid string Yes The ID of the log you want to retrieve.

Returns

Data Type Description of Returned Data
string Returns a string containing the log note or false if the log entry with the provided ID does not exist. The type of data returned depends on the custom hook executed within the function.

Further Documentation:

The lognote function is a helper function in UserSpice, a PHP user management framework, that allows you to customize the content of the admin logs. It takes a single argument $logid which is the ID of the log you want to retrieve.

The function first retrieves the log entry from the database using the $logid parameter. If the log entry exists, it checks the logtype column of the entry and executes the corresponding custom hook for that log type.

Here's an example usage of the lognote function to retrieve the page title from the log entry:

$logid = 123; // ID of the log entry
$lognote = lognote($logid); // Get the lognote from the log entry
if ($lognote !== false && $logtype === 'Page') { // Check if the lognote exists and the logtype is 'Page'
$pageTitle = $lognote; // Assume that the lognote contains the page ID
// Retrieve the page title from the database
$db = DB::getInstance();
$pageQ = $db->query("SELECT title FROM pages WHERE id = ?",[$pageTitle]);
if($pageQ->count() > 0) {
$pageTitle = $pageQ->first()->title; // Get the page title
} else {
$pageTitle = 'Error finding page information';
}
// Do something with the page title
}



Note that the lognote function needs to be placed in the custom_functions.php file in the includes directory of UserSpice. It is recommended to override the function in the custom functions file rather than editing the core files to avoid issues with future updates.