CSS User Badge & Stars
Wolf Offline
Junior Member
**
Posts: 11
Joined: Aug 2017
Post: #6
RE: CSS User Badge & Stars
I've managed to find a tutorial online, and done it. There's also one more problem I can't seem to figure out in php code the group label I'm using I've managed to change the php codes around to work on postbit, user cp.. But I can't seem to do profile and memberlist I basically need it to replace usertitle not user group image. Here's the code..

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php

/*
        Groupimage to label text [v1.2]
      (c) Copyright 2013-2016 by Inferno
 
      @author    : Inferno (http://www.Inferno24.pl)
      @contact   : inferno.piotr@gmail.com
      @date      : 03-02-2016
      @update    : 17-11-2017

*/

if(!defined("IN_MYBB")){
	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook("postbit", "rank_postbit");
$plugins->add_hook("member_profile_end", "rank_profile");
$plugins->add_hook("usercp_end", "rank_usercp");
$plugins->add_hook("memberlist_user", "rank_memberlist");

function labelrank_info(){
	global $lang;
	$lang->load("labelrank_group");
	return array(
		'name'			=> 'Groupimage to label text',
		'description'	=> $lang->agi_descr,
		'website'		=> 'http://www.inferno24.pl',
		'author'		=> 'Inferno',
		'authorsite'	=> 'http://www.Inferno24.pl',
		'version'		=> '1.2',
		'guid'			=> 'bab9eaae39210fd31d6c31c4fe4c9baf',
		'codename'		=> 'groupimage_to_labeltext'
	);
}
function labelrank_activate(){
    global $db,$lang;
	$lang->load("labelrank_group");
    $group = array(
        "gid"            => "NULL",
        "title"          => "Group Label",
        "name"           => "labelrank_group",
        "description"    => $lang->setting_description,
        "disporder"      => "1",
        "isdefault"      => "0",
    );
    
    $db->insert_query("settinggroups", $group);
    $gid = $db->insert_id();
    
    
    $setting_1 = array(
        "sid"            => "NULL",
        "name"           => "labelrank_postbit",
        "title"          => $lang->postbit_title,
        "description"    => $lang->postbit_descr,
        "optionscode"    => "yesno",
        "value"          => 'yes',
        "disporder"      => '1',
        "gid"            => intval($gid),
    );

    $db->insert_query("settings", $setting_1);

    $setting_2 = array(
        "sid"            => "NULL",
        "name"           => "labelrank_profile",
        "title"          => $lang->profile_title,
        "description"    => $lang->profile_descr,
        "optionscode"    => "yesno",
        "value"          => 'yes',
        "disporder"      => '1',
        "gid"            => intval($gid),
    );

    $db->insert_query("settings", $setting_2);

    $setting_3 = array(
        "sid"            => "NULL",
        "name"           => "labelrank_usercp",
        "title"          => $lang->usercp_title,
        "description"    => $lang->usercp_descr,
        "optionscode"    => "yesno",
        "value"          => 'yes',
        "disporder"      => '1',
        "gid"            => intval($gid),
    );

    $db->insert_query("settings", $setting_3);

    $setting_4 = array(
        "sid"            => "NULL",
        "name"           => "labelrank_memberlist",
        "title"          => $lang->memberlist_title,
        "description"    => $lang->memberlist_descr,
        "optionscode"    => "yesno",
        "value"          => 'yes',
        "disporder"      => '1',
        "gid"            => intval($gid),
    );

    $db->insert_query("settings", $setting_4);

    rebuild_settings();

    require_once MYBB_ROOT."/inc/adminfunctions_templates.php";

	find_replace_templatesets(
		"memberlist_user",
		"#" . preg_quote('{$usergroup[\'groupimage\']}') . "#i",
		'{$group_label}<br />'
	);
}
function labelrank_deactivate(){
    global $db;

	$db->delete_query("settinggroups", "name=\"labelrank_group\"");
	$db->delete_query("settings", "name LIKE \"labelrank%\"");

	require_once MYBB_ROOT."/inc/adminfunctions_templates.php";

	find_replace_templatesets(
		"memberlist_user",
		"#" . preg_quote('{$group_label}<br />') . "#i",
		'{$usergroup[\'groupimage\']}'
	);
    rebuild_settings();
} 

function rank_postbit(&$post){	
	global $mybb;

	if($mybb->settings['labelrank_postbit']){
		$usertitle = getgroupname($post['usertitle']);
		$post['usertitle'] = "<div class=\"profile-rank\"><span class=\"gid-".$post['usergroup']."\">".($post['usertitle'])."</span></div>";
	}
	
}
function rank_profile(){	
	global $mybb, $memprofile, $groupimage, $usertitle;

	if($mybb->settings['labelrank_profile']){
		$usertitle = getgroupname($memprofile['usertitle']);
		$usergroup = "<div class=\"profile-rank\"><span class=\"gid-".$memprofile['usergroup']."\">".($memprofile['usertitle'])."</span></div>";
	}
}

function rank_usercp(){
	global $mybb, $user, $usergroup, $usertitle;

	if($mybb->settings['labelrank_usercp']){
		$usertitle = getgroupname($mybb->user['usertitle']);
		$usergroup = "<div class=\"profile-rank\"><span class=\"gid-".$mybb->user['usergroup']."\">".($mybb->user['usertitle'])."</span></div>";
	}
}

function rank_memberlist(){
	global $mybb, $user, $group_label;
	if($mybb->settings['labelrank_memberlist']){
		$groupname = getgroupname($user['usergroup']);
		eval("\$group_label = '<div class=\"profile-rank\"><span class=\"gid-".$user['usergroup']."\">".$groupname."</span></div>';");
	}
}

function getgroupname($usertitle){
	global $cache;

	$usergroups = $cache->read("usergroups");
	$usertitle=$usergroups[$usertitle]['usertitle'];
	return $usertitle;
}
?>

12-22-2017 04:35 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
CSS User Badge & Stars - Wolf - 12-19-2017, 12:42 PM
RE: CSS User Badge & Stars - Wolf - 12-21-2017, 02:51 AM
RE: CSS User Badge & Stars - RateU - 12-21-2017, 06:15 AM
RE: CSS User Badge & Stars - Wolf - 12-21-2017, 06:53 AM
RE: CSS User Badge & Stars - RateU - 12-21-2017, 10:04 PM
RE: CSS User Badge & Stars - Wolf - 12-22-2017 04:35 AM

 Standard Tools
Forum Jump: