What I have done so far is to write a function which I call on another page:
<div style="<?php echo groupColor($_SESSION['username']); ?>"><?php echo $_SESSION['username']; ?></div>
What it does it that retrieves the username_css
style from the xf_user_group
and that way I can color the user's username by the color they have on a xenforo forum board (all username_css contain color: #somecolorcode;
)
function groupColor($username) {
global $xenforo;
$xf_getuser = $xenforo->query("SELECT * FROM xf_user WHERE username = '".$username."'");
if($xf_getuser->num_rows >= 1) {
$fetch_xf_getuser = $xf_getuser->fetch_array();
$fetch_xf_getuser_group = $fetch_xf_getuser["display_style_group_id"];
$xf_getgroupstyle = $xenforo->query("SELECT * FROM xf_user_group WHERE user_group_id = '".$fetch_xf_getuser_group."'");
if($xf_getgroupstyle->num_rows >= 1) {
$fetch_xf_getgroupstyle = $xf_getgroupstyle->fetch_array();
$result_forum_css = $fetch_xf_getgroupstyle["username_css"];
return $result_forum_css;
} else {
die(mysqli_error($xenforo));
}
} else {
die(mysqli_error($xenforo));
}
}
What I am looking to do now, is to only extract color: #somecolorcode;
from username_css
so I can use it to color a background instead, like this: background-color: #somecolorcode;
Any idea how I should continue? All help is appreciated, and sorry for the bad title, I'm not of sure what the method is called.
EDIT 1:
The username_css
row does not only contain color: #colorcode;
but also stuff like: font-weight: bold;
font-style: italic;
color: red;