Collections functions
General functions
Render functions
Theme permission functions
Resource functions

get_default_user_collection()

Description

Get the user's default collection, creating one if necessary

Parameters

ColumnTypeDefaultDescription
$setactive bool false Set the collection as the user's active collection?

Return

int collection ID

Location

include/collections_functions.php lines 6765 to 6782

Definition

 
function get_default_user_collection($setactive=false)
    {
    global 
$userref;
    
$usercollection ps_value("SELECT ref value FROM collection WHERE user=? AND name LIKE 'Default Collection%' ORDER BY created ASC LIMIT 1",array("i",$userref),0);
    if (
$usercollection == 0)
        {
        
# Create a collection for this user
        # The collection name is translated when displayed!
        
$usercollection=create_collection($userref,"Default Collection",0,1); # Do not translate this string!
        
}
    if(
$setactive)
        {
        
# set this to be the user's current collection
        
ps_query("UPDATE user SET current_collection=? where ref=?",array("i",$usercollection,"i",$userref));
        
set_user_collection($userref,$usercollection);
        }
    return 
$usercollection;
    }

This article was last updated 26th September 2022 13:35 Europe/London time based on the source file dated 22nd September 2022 11:00 Europe/London time.