PDA

View Full Version : array_merge


wolfe
05-06-2014, 07:45 AM
IS it possible for me to add custom userinfo to the fetch_userinfo() array to be then called with the fetch_userinfo() array anywhere on the site.

example i have a custom rating system based on post counts. what i want to do is do the return on it and then merge the result into the user info array.

kh99
05-06-2014, 08:06 AM
If you add columns to the user table, they will load with the rest of the userdata and you won't have to do anything. If you use a separate table with a userid column, then you can use a plugin at hook location fetch_userinfo_query and set the variables $hook_query_fields and $hook_query_joins to add your table to the query. For example:
$hook_query_fields .= ', mytable.*';
$hook_query_joins .= ' LEFT JOIN mytable ON (mytable.userid = user.userid) ';

See includes/functions.php, function fetch_userinfo().

Edit: I just reread what you posted - if you don't want to read your info directly from the database, you could instead use a plugin on hook fetch_userinfo to do whatever you have to to find the data for user $userid, then add your info to the $user array.

wolfe
05-06-2014, 10:04 AM
thanks will give it ago and let you know :)