Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[For 1.8] Style Your Nick
#1
Allows users to change their nickname styling in the User CP (based on group permissions). Should work in both 1.8 and it may work in 1.6 after some changes. More info in the download link and on the github page.

[Image: preview_58253_1421614303_e3b2a203dd0a44e...89f52d.png]
[Image: preview_58253_1421614325_3c6a186a9b9964c...70aee6.png]
[Image: preview_58253_1421614334_e41279805f476a0...4585c1.png]
[Image: preview_58253_1421614344_4a7dec036b24b68...7dc453.png]

Requirements:
Plugin Library - https://github.com/frostschutz/MyBB-Plug...master.zip
If you're using PostgreSQL, 9.1 is the minimum for this plugin.

Bug reports/enhancement requests:
https://github.com/Destroy666x/MyBB-Style-Your-Nick

Lang packs:
Since the current way of adding lang packs is not really good, PM me and I'll add you as contributor.

Download:
http://community.mybb.com/mods.php?action=view&pid=368
Reply
#2
Thats awesome! INstalling right now!
Reply
#3
Seems like you are doing only one query per page, by at a first glance is better than many other methods used in plugins. Even I do a query per username in my newpoints plugin, which is nonsense.
https://github.com/Sama34/Newpoints-Buy-...t.php#L342

I would rather recommend the use of the pre_output_page hook if possible to make a mass replace of all usernames with a less heavy query since you are getting all users with a custom username instead of just the ones displayed in the page.

pre_output_page has its limitations, for example, in modals windows where username may be displayed so it could be a tricky path that could probably require frequent updates to work around found issues like this.

Anyways, just wanted to give my input, it is yet seems better that anything currently out there, cheers!
Reply
#4
Thanks, not going to work on optimisations anymore though, since it should be ok if the "Use default styling.." option is not turned off in any group. Then the simplier query with less rows is used (recommended for big boards). And I need it in the format_name() function for another modification on the forum I'm working on.

EDIT2: I added a note in the checkbox label to warn admins of big boards. And after a further check your solution wouldn't unfortunately work well with formatted guests names since in some cases they may be the same as registered user names.

EDIT: added old styling records (users which don't have permissions to use it anymore) clean-up to the to-do list, probably will add it to the user cleanup task.
Reply
#5
Current username style for people who are premium on my website (paid users) get the username:

<span style="color: #1f5a79; text-shadow: 0px 0px 2px #143d4c;">+{username}</span>

Whenever they choose to change their nick the + goes away. Is there a way to make it stay?
Reply
#6
There is no way currently. The whole group styling is replaced by the user styling. You'd have to edit the format_name() function inside inc/funcions.php to add the + in front of the nickname for that group.

Find:
if($style)
		$format = "<span style="$style">{username}</span>";
	elseif(!$u["syn_usedefault"])
Replace with:
if($style)
{
	if($usergroup == 4) // change 4 to the usergroup id
		$format = '+';	

	$format .= "<span style="$style">{username}</span>";
}
elseif(!$u["syn_usedefault"])

I might add a prefix/suffix group option that's not changeable by users to possibly differentiate them from other groups, not sure if I will.
Reply
#7
(2015-01-18, 11:52 PM)Destroy666 Wrote: There is no way currently. The whole group styling is replaced by the user styling. You'd have to edit the format_name() function inside inc/funcions.php to add the + in front of the nickname for that group.

Find:
if($style)
		$format = "<span style="$style">{username}</span>";
	elseif(!$u["syn_usedefault"])
Replace with:
if($style)
{
	if($usergroup == 4) // change 4 to the usergroup id
		$format = '+';	

	$format .= "<span style="$style">{username}</span>";
}
elseif(!$u["syn_usedefault"])

I might add a prefix/suffix group option that's not changeable by users to possibly differentiate them from other groups, not sure if I will.

functions.php is seen as:

/* + PL:style_your_nick + */ 	if($style)

/* + PL:style_your_nick + */ 		$format = "<span style=\"$style\">{username}</span>";

/* + PL:style_your_nick + */ 	elseif(!$u["syn_usedefault"])

What do I do to fix it with those extra texts?
Reply
#8
Add /* + PL:style_your_nick + */ at the beginning of every line in the code I posted above.
Reply
#9
(2015-01-19, 12:18 AM)Destroy666 Wrote: Add /* + PL:style_your_nick + */ at the beginning of every line in the code I posted above.

It makes my website blank.

Using:

/* + PL:style_your_nick + */ if($style)
/* + PL:style_your_nick + */ {
/* + PL:style_your_nick + */     if($usergroup == 4) // change 4 to the usergroup id
/* + PL:style_your_nick + */         $format = '+';    
/* + PL:style_your_nick + */ 
/* + PL:style_your_nick + */     $format .= "<span style="$style">{username}</span>";
/* + PL:style_your_nick + */ }
/* + PL:style_your_nick + */ elseif(!$u["syn_usedefault"]) 

It is shown as the lines being spaced on every code, but kinda confusing/

^^ Definitely doesnt look right lol
Reply
#10
Oh, change
$format .= "<span style="$style">{username}</span>";
to:
$format .= "<span style=\"$style\">{username}</span>";
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)