PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 1.0.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v1.0.3
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.3, at profile-builder.php

116 lines 5.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Profile Builder
4 Plugin URI: http://www.cozmoslabs.com/2011/04/12/wordpress-profile-builder-a-front-end-user-registration-login-and-edit-profile-plugin/
5 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.
6 Version: 1.0.3
7 Author: Reflection Media
8 Author URI: http://reflectionmedia.ro
9 License: GPL2
10 */
11
12 /* Copyright 2011 Reflection Media (wwww.reflectionmedia.ro)
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
26 register_activation_hook( __FILE__ , 'wppb_initialize_variables' ); //initialize some values upon plug-in activation
27 function wppb_initialize_variables(){
28 $wppb_default_settings = array( 'username' => 'show',
29 'firstname'=> 'show',
30 'lastname' => 'show',
31 'nickname' => 'show',
32 'dispname' => 'show',
33 'email' => 'show',
34 'website' => 'show',
35 'aim' => 'show',
36 'yahoo' => 'show',
37 'jabber' => 'show',
38 'bio' => 'show',
39 'password' => 'show' );
40 add_option( 'wppb_default_settings', $wppb_default_settings ); //set all fields visible on first activation of the plugin
41 add_option( 'wppb_default_style', 'yes');
42
43 global $wp_roles;
44 $all_roles = $wp_roles->roles;
45 $editable_roles = apply_filters('editable_roles', $all_roles);
46
47 $admintSettingsPresent = get_option('wppb_display_admin_settings','not_found');
48
49 if ($admintSettingsPresent == 'not_found'){ // if the field doesn't exists, then create it
50 $rolesArray = array();
51 foreach ( $editable_roles as $key => $data )
52 $rolesArray = array( $key => 'show' ) + $rolesArray;
53 $rolesArray = array_reverse($rolesArray,true);
54 add_option( 'wppb_display_admin_settings', $rolesArray);
55 }
56 }
57
58
59 function wppb_create_menu(){
60 add_submenu_page('users.php', 'Profile Builder', 'Profile Builder', 'delete_users', 'ProfileBuilderSettings', 'wppb_display_menu');
61 }
62
63
64 function wppb_register_settings() { // whitelist options, you can add more register_settings changing the second parameter
65 register_setting( 'wppb-option-group', 'wppb_default_settings' );
66 register_setting( 'wppb_default_style', 'wppb_default_style' );
67 register_setting( 'wppb_display_admin_settings', 'wppb_display_admin_settings' );
68 }
69
70
71 function wppb_add_plugin_stylesheet() {
72 $wppb_showDefaultCss = get_option('wppb_default_style');
73 $styleUrl = WP_PLUGIN_URL . '/profile-builder/css/style.css';
74 $styleFile = WP_PLUGIN_DIR . '/profile-builder/css/style.css';
75 if ( file_exists($styleFile) && $wppb_showDefaultCss == 'yes') {
76 wp_register_style('wppb_stylesheet', $styleUrl);
77 wp_enqueue_style( 'wppb_stylesheet');
78 }
79 }
80
81
82 function wppb_show_admin_bar($content){
83 global $current_user;
84 $admintSettingsPresent = get_option('wppb_display_admin_settings','not_found');
85 if ($admintSettingsPresent != 'not_found'){
86 $wppb_showAdminBar = get_option('wppb_display_admin_settings');
87 $userRole = ($current_user->data->wp_capabilities);
88 if ($userRole != NULL){
89 $currentRole = key($userRole);
90 $getSettings = $wppb_showAdminBar[$currentRole];
91 if ($getSettings == 'show')
92 return true;
93 elseif ($getSettings == 'hide')
94 return false;
95 }
96 }
97 else
98 return true;
99 }
100
101
102 if (is_admin() ){ // if we are in the admin menu
103 include_once('includes/wppb-menu-file.php'); // include the menu file
104 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"
105 add_action('admin_menu','wppb_create_menu'); // call the wppb_create_menu function
106 }else{ // if we aren't in the admin back-end menu, aka we are in the front-end view
107 add_action('wp_print_styles', 'wppb_add_plugin_stylesheet'); // include the standard style-sheet or specify the path to a new one
108 include_once('includes/wppb-front-end-profile.php'); // include the menu file for the profile informations
109 add_shortcode('wppb-edit-profile', 'wppb_front_end_profile_info');
110 include_once('includes/wppb-front-end-login.php'); // include the menu file for the login screen
111 add_shortcode('wppb-login', 'wppb_front_end_login');
112 include_once('includes/wppb-front-end-register.php'); // include the menu file for the register screen
113 add_shortcode('wppb-register', 'wppb_front_end_register');
114 add_filter( 'show_admin_bar' , 'wppb_show_admin_bar'); // set the front-end admin bar to show/hide
115 }
116