PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 1.0.1
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v1.0.1
4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 All 339 releases
profile-builder / profile-builder.php

profile-builder.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 1.0.1, at profile-builder.php

261 lines 5.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4
5 Plugin Name: Profile Builder
6
7 Plugin URI:
8
9 Description: Profile Builder lets you create, edit and delete custom user information-fields from the frontend, and also lets you add new, custom fields. You can use the following shortcodes: [wppb-edit-profile] for the front-end profile information, [wppb-login] for a log-in menu or [wppb-register] to register a new user.
10
11 Version: v1.0
12
13 Author: Reflection Media
14
15 Author URI: http://reflectionmedia.ro
16
17 License: GPL2
18
19 */
20
21
22
23
24
25 /* Copyright 2011 Reflection Media (wwww.reflectionmedia.ro)
26
27 This program is free software; you can redistribute it and/or modify
28
29 it under the terms of the GNU General Public License as published by
30
31 the Free Software Foundation; either version 2 of the License, or
32
33 (at your option) any later version.
34
35 This program is distributed in the hope that it will be useful,
36
37 but WITHOUT ANY WARRANTY; without even the implied warranty of
38
39 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40
41 GNU General Public License for more details.
42
43 You should have received a copy of the GNU General Public License
44
45 along with this program; if not, write to the Free Software
46
47 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
48
49 */
50
51
52
53
54
55 register_activation_hook( __FILE__ , 'wppb_initialize_variables' ); //initialize some values upon plug-in activation
56
57 function wppb_initialize_variables(){
58
59 $wppb_default_settings = array( 'username' => 'show',
60
61 'firstname'=> 'show',
62
63 'lastname' => 'show',
64
65 'nickname' => 'show',
66
67 'dispname' => 'show',
68
69 'email' => 'show',
70
71 'website' => 'show',
72
73 'aim' => 'show',
74
75 'yahoo' => 'show',
76
77 'jabber' => 'show',
78
79 'bio' => 'show',
80
81 'password' => 'show' );
82
83 add_option( 'wppb_default_settings', $wppb_default_settings ); //set all fields visible on first activation of the plugin
84
85 add_option( 'wppb_default_style', 'yes');
86
87
88
89
90
91
92
93 global $wp_roles;
94
95
96
97 $all_roles = $wp_roles->roles;
98
99 $editable_roles = apply_filters('editable_roles', $all_roles);
100
101
102
103
104
105 $admintSettingsPresent = get_option('wppb_display_admin_settings','not_found');
106
107 if ($admintSettingsPresent == 'not_found'){ // if the field doesn't exists, then create it
108
109 $rolesArray = array();
110
111 foreach ( $editable_roles as $key => $data )
112
113 $rolesArray = array( $key => 'show' ) + $rolesArray;
114
115 $rolesArray = array_reverse($rolesArray,true);
116
117 add_option( 'wppb_display_admin_settings', $rolesArray);
118
119 }
120
121
122
123 }
124
125
126
127
128
129
130
131 function wppb_create_menu(){
132
133 add_submenu_page('users.php', 'Profile Builder', 'Profile Builder', 'delete_users', 'ProfileBuilderSettings', 'wppb_display_menu');
134
135 }
136
137
138
139
140
141 function wppb_register_settings() { // whitelist options, you can add more register_settings changing the second parameter
142
143 register_setting( 'wppb-option-group', 'wppb_default_settings' );
144
145 register_setting( 'wppb_default_style', 'wppb_default_style' );
146
147 register_setting( 'wppb_display_admin_settings', 'wppb_display_admin_settings' );
148
149 }
150
151
152
153
154
155 function wppb_add_plugin_stylesheet() {
156
157 $wppb_showDefaultCss = get_option('wppb_default_style');
158
159 $styleUrl = WP_PLUGIN_URL . '/profile-builder/css/style.css';
160
161 $styleFile = WP_PLUGIN_DIR . '/profile-builder/css/style.css';
162
163 if ( file_exists($styleFile) && $wppb_showDefaultCss == 'yes') {
164
165 wp_register_style('wppb_stylesheet', $styleUrl);
166
167 wp_enqueue_style( 'wppb_stylesheet');
168
169 }
170
171 }
172
173
174
175
176
177
178
179
180
181 function wppb_show_admin_bar($content){
182
183 global $current_user;
184
185
186
187 $admintSettingsPresent = get_option('wppb_display_admin_settings','not_found');
188
189
190
191 if ($admintSettingsPresent != 'not_found'){
192
193 $wppb_showAdminBar = get_option('wppb_display_admin_settings');
194
195 $userRole = ($current_user->data->wp_capabilities);
196
197 if ($userRole != NULL){
198
199 $currentRole = key($userRole);
200
201 $getSettings = $wppb_showAdminBar[$currentRole];
202
203 if ($getSettings == 'show')
204
205 return true;
206
207 elseif ($getSettings == 'hide')
208
209 return false;
210
211 }
212
213 }
214
215 else
216
217 return true;
218
219 }
220
221
222
223
224
225
226
227
228
229
230
231
232
233 if (is_admin() ){ // if we are in the admin menu
234
235 include_once('includes/wppb-menu-file.php'); // include the menu file
236
237 add_action('admin_init', 'wppb_register_settings'); // register the settings for the menu only display sidebar menu for a user with a certain capability, in this case only the "admin"
238
239 add_action('admin_menu','wppb_create_menu'); // call the wppb_create_menu function
240
241 }else{ // if we aren't in the admin back-end menu, aka we are in the front-end view
242
243 add_action('wp_print_styles', 'wppb_add_plugin_stylesheet'); // include the standard style-sheet or specify the path to a new one
244
245 include_once('includes/wppb-front-end-profile.php'); // include the menu file for the profile informations
246
247 add_shortcode('wppb-edit-profile', 'wppb_front_end_profile_info');
248
249 include_once('includes/wppb-front-end-login.php'); // include the menu file for the login screen
250
251 add_shortcode('wppb-login', 'wppb_front_end_login');
252
253 include_once('includes/wppb-front-end-register.php'); // include the menu file for the register screen
254
255 add_shortcode('wppb-register', 'wppb_front_end_register');
256
257 add_filter( 'show_admin_bar' , 'wppb_show_admin_bar'); // set the front-end admin bar to show/hide
258
259 }
260
261