Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

get_user_message()

Description

Gets the user message for the given ref


False if user has no access or the requested message doesn't exist,

Parameters

ColumnTypeDefaultDescription
$ref int Message ID
$checkaccess bool true Check if user can see the given message?

Return

array|bool Array with two elements: 'message' => message text,'url'=> message URL and 'owner' => message owner

Location

include/message_functions.php lines 1156 to 1170

Definition

 
function get_user_message(int $refbool $checkaccess=true)
    {
    global 
$userref;
    if(
$checkaccess)
        {
        
$validmessages ps_array("SELECT `message` value FROM user_message WHERE user = ?",["i",$userref]);
        if(!
in_array($ref,$validmessages))
            {
            return 
false;
            }
        }
    
$message ps_query("SELECT message, url, owner FROM message WHERE ref = ?",["i",$ref]);

    return 
$message ? ["message"=>$message[0]["message"],"url"=>$message[0]["url"],"owner"=>$message[0]["owner"]] : false;
    }

This article was last updated 29th May 2024 12:35 Europe/London time based on the source file dated 20th May 2024 10:55 Europe/London time.