Post Reply 
Need help with php
Plugin->Zinga's plugin username colors
Author Message
Pirata Nervo
NervOS Developer

Posts: 699.4765
Threads: 39
Joined: 20th Jun 2007
Reputation: -0.79225
E-Pigs: 19.2466
Offline
Post: #1
Need help with php
Im trying to make a plugin like zinga's plugin(username color just that), im trying to make this:

replace in functions.php:
this:

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function format_name($username, $usergroup, $displaygroup="")
{
	global $groupscache, $cache;

	if(!is_array($groupscache))
	{
		$groupscache = $cache->read("usergroups");
	}

	if($displaygroup != 0)
	{
		$usergroup = $displaygroup;
	}
	
	
	$ugroup = $groupscache[$usergroup];
	$format = $ugroup['namestyle'];
	$userin = substr_count($format, "{username}");
	if($userin == 0)
	{
		$format = "{username}";
	}
	$format = stripslashes($format);
	return str_replace("{username}", $username, $format);
}

with this:

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function format_name($username, $usergroup, $displaygroup="")
{
	global $db, $groupscache, $cache;
	$query = $db->simple_select(TABLE_PREFIX."userfields", "fid5", "ufid='".intval($uid)."'");

	if(!is_array($groupscache))
	{
		$groupscache = $cache->read("usergroups");
	}

	if($displaygroup != 0)
	{
		$usergroup = $displaygroup;
	}
	$ugroup = $groupscache[$usergroup];
	$format = "<span style=\"color:{$userfields['fid5']};\">{username}</span>"; // This the 'namestyle' can be easily changed in the admin cp for each group but i want to change it for each user
	$userin = substr_count($format, "{username}"); // function that counts how many times {username} substring is in the $formats string
	if($userin == 0) // if {username} substring wasnt found in the $format string, then
	{
		$format = "{username}"; // the $format string = "{username}"
	}
	$format = stripslashes($format); // The stripslashes() function removes backslashes from the $format string
	return str_replace("{username}", $username, $format); // replaces {username} with $username, so the $format string will contain $username instead of {username}
}


It doesn't show the colors...but it affects the colors because it shows the default color in all usernames


(This post was last modified: 07/09/2007 04:03 PM by Pirata Nervo.)
07/09/2007 07:13 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
Need help with php - Pirata Nervo - 07/09/2007 07:13 AM
RE: Need help with php - Th3_Hellrider - 07/09/2007, 08:52 AM
RE: Need help with php - Pirata Nervo - 07/09/2007, 09:12 AM
RE: Need help with php - Pirata Nervo - 07/09/2007, 03:36 PM
RE: Need help with php - ZiNgA BuRgA - 07/09/2007, 09:10 PM
RE: Need help with php - Pirata Nervo - 08/09/2007, 12:45 AM
RE: Need help with php - Pirata Nervo - 08/09/2007, 05:58 AM
RE: Need help with php - ZiNgA BuRgA - 08/09/2007, 07:11 PM
RE: Need help with php - Pirata Nervo - 09/09/2007, 02:25 AM
RE: Need help with php - ZiNgA BuRgA - 09/09/2007, 05:10 AM
RE: Need help with php - Pirata Nervo - 09/09/2007, 06:09 AM
RE: Need help with php - ZiNgA BuRgA - 09/09/2007, 06:12 PM
RE: Need help with php - Pirata Nervo - 10/09/2007, 02:38 AM
RE: Need help with php - ZiNgA BuRgA - 10/09/2007, 03:07 AM
RE: Need help with php - Pirata Nervo - 10/09/2007, 03:24 AM
RE: Need help with php - Pirata Nervo - 10/09/2007, 02:53 PM
RE: Need help with php - ZiNgA BuRgA - 10/09/2007, 04:12 PM
RE: Need help with php - Pirata Nervo - 11/09/2007, 01:41 AM
RE: Need help with php - ZiNgA BuRgA - 11/09/2007, 03:54 AM
RE: Need help with php - Pirata Nervo - 11/09/2007, 04:00 AM
RE: Need help with php - Pirata Nervo - 11/09/2007, 04:20 AM
RE: Need help with php - Pirata Nervo - 11/09/2007, 04:05 PM
RE: Need help with php - ZiNgA BuRgA - 11/09/2007, 08:50 PM
RE: Need help with php - Pirata Nervo - 12/09/2007, 01:43 AM
RE: Need help with php - Pirata Nervo - 12/09/2007, 07:36 AM
RE: Need help with php - ZiNgA BuRgA - 12/09/2007, 03:32 PM
RE: Need help with php - Pirata Nervo - 12/09/2007, 03:55 PM
RE: Need help with php - ZiNgA BuRgA - 12/09/2007, 04:11 PM
RE: Need help with php - Pirata Nervo - 12/09/2007, 04:22 PM
RE: Need help with php - Pirata Nervo - 17/09/2007, 01:16 PM
RE: Need help with php - ZiNgA BuRgA - 17/09/2007, 04:57 PM
RE: Need help with php - Pirata Nervo - 18/09/2007, 01:40 AM

Forum Jump:


User(s) browsing this thread: 5 Guest(s)

 Quick Theme: