get_config_option()

Description

Get config option value from the database (system wide -or- a user preference).

IMPORTANT: it falls back (defaults) to the globally scoped config option value if
there's nothing in the database.
global setting e.g. for checking admin resource preferences

Parameters

ColumnTypeDefaultDescription
$user_id ?integer Current user ID. Use NULL to get the system wide setting.
$name string Parameter name
&$returned_value
$default mixed null Optionally used to set a default that may not be the current
$returned_value string The config value will be returned through this parameter which is passed by reference.

Return

boolean Indicates if the config option was found in the database or not.

Location

include/config_functions.php lines 254 to 288

Definition

 
function get_config_option($user_id$name, &$returned_value$default null)
    {
    if(
trim($name) === '')
        {
        return 
false;
        }

    if(
is_null($user_id))
        {
        
$user_query 'user IS NULL';
        }
    else    
        {
        
$user_query 'user = ?';
        
$params[] = 'i'$params[] = $user_id;
        }

    
$query "SELECT `value` FROM user_preferences WHERE "$user_query ." AND parameter = ?";
    
$params[] = "s"$params[] = $name;
    
$config_option ps_value($query,$paramsnull"preferences");

    if(
is_null($default) && isset($GLOBALS[$name]))
        {
        
$default $GLOBALS[$name];
        }

     if(
is_null($config_option))
        {
        
$returned_value $default;
        return 
false;
        }

    
$returned_value unescape($config_option);
    return 
true;
    }

This article was last updated 5th April 2025 16:35 Europe/London time based on the source file dated 2nd April 2025 14:45 Europe/London time.