Version Description
- Compatibility fix with php 7.1
- Redirects code refactoring which should fix some minor issues with redirects as well
Download this release
Release Info
| Developer | madalin.ungureanu |
| Plugin | |
| Version | 2.5.6 |
| Comparing to | |
| See all releases | |
Code changes from version 2.5.5 to 2.5.6
- assets/lib/wck-api/wordpress-creation-kit.php +4 -0
- features/functions.php +58 -0
- front-end/class-formbuilder.php +101 -139
- front-end/edit-profile.php +0 -9
- front-end/login.php +15 -31
- front-end/logout.php +8 -12
- front-end/recover.php +6 -18
- front-end/register.php +12 -23
- index.php +5 -5
- readme.txt +6 -2
assets/lib/wck-api/wordpress-creation-kit.php
CHANGED
|
@@ -799,6 +799,10 @@ class Wordpress_Creation_Kit_PB{
|
|
| 799 |
else if ( $this->args['context'] == 'option' )
|
| 800 |
$results = get_option( apply_filters( 'wck_option_meta' , $meta, $values ) );
|
| 801 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 802 |
/* for single metaboxes owerwrite entries each time so we have a maximum of one */
|
| 803 |
if( $this->args['single'] )
|
| 804 |
$results = array( $values );
|
| 799 |
else if ( $this->args['context'] == 'option' )
|
| 800 |
$results = get_option( apply_filters( 'wck_option_meta' , $meta, $values ) );
|
| 801 |
|
| 802 |
+
/* we need an array here */
|
| 803 |
+
if( empty( $results ) && !is_array( $results ) )
|
| 804 |
+
$results = array();
|
| 805 |
+
|
| 806 |
/* for single metaboxes owerwrite entries each time so we have a maximum of one */
|
| 807 |
if( $this->args['single'] )
|
| 808 |
$results = array( $values );
|
features/functions.php
CHANGED
|
@@ -967,3 +967,61 @@ function wppb_can_users_signup_blog(){
|
|
| 967 |
}
|
| 968 |
return false;
|
| 969 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 967 |
}
|
| 968 |
return false;
|
| 969 |
}
|
| 970 |
+
|
| 971 |
+
/**
|
| 972 |
+
* Function that handle redirect URL
|
| 973 |
+
*
|
| 974 |
+
* @param string $redirect_priority - it can be normal or top priority
|
| 975 |
+
* @param string $redirect_type - type of the redirect
|
| 976 |
+
* @param null|string $redirect_url - redirect URL if already set
|
| 977 |
+
* @param null|string|object $user - username, user email or user data
|
| 978 |
+
* @param null|string $user_role - user role
|
| 979 |
+
*
|
| 980 |
+
* @return null|string $redirect_url
|
| 981 |
+
*/
|
| 982 |
+
function wppb_get_redirect_url( $redirect_priority = 'normal', $redirect_type, $redirect_url = NULL, $user = NULL, $user_role = NULL ) {
|
| 983 |
+
if( PROFILE_BUILDER == 'Profile Builder Pro' ) {
|
| 984 |
+
$wppb_module_settings = get_option( 'wppb_module_settings' );
|
| 985 |
+
|
| 986 |
+
if( isset( $wppb_module_settings['wppb_customRedirect'] ) && $wppb_module_settings['wppb_customRedirect'] == 'show' && $redirect_priority != 'top' && function_exists( 'wppb_custom_redirect_url' ) ) {
|
| 987 |
+
$redirect_url = wppb_custom_redirect_url( $redirect_type, $redirect_url, $user, $user_role );
|
| 988 |
+
}
|
| 989 |
+
}
|
| 990 |
+
|
| 991 |
+
if( ! empty( $redirect_url ) ) {
|
| 992 |
+
$redirect_url = ( wppb_check_missing_http( $redirect_url ) ? 'http://'. $redirect_url : $redirect_url );
|
| 993 |
+
}
|
| 994 |
+
|
| 995 |
+
return $redirect_url;
|
| 996 |
+
}
|
| 997 |
+
|
| 998 |
+
/**
|
| 999 |
+
* Function that builds the redirect
|
| 1000 |
+
*
|
| 1001 |
+
* @param string $redirect_url - redirect URL
|
| 1002 |
+
* @param int $redirect_delay - redirect delay in seconds
|
| 1003 |
+
* @param null|string $redirect_type - the type of the redirect
|
| 1004 |
+
* @param null|array $form_args - form args if set
|
| 1005 |
+
*
|
| 1006 |
+
* @return string $redirect_message
|
| 1007 |
+
*/
|
| 1008 |
+
function wppb_build_redirect( $redirect_url, $redirect_delay, $redirect_type = NULL, $form_args = NULL ) {
|
| 1009 |
+
if( isset( $redirect_type ) ) {
|
| 1010 |
+
$redirect_url = apply_filters( 'wppb_'. $redirect_type .'_redirect', $redirect_url );
|
| 1011 |
+
}
|
| 1012 |
+
|
| 1013 |
+
$redirect_message = '';
|
| 1014 |
+
|
| 1015 |
+
if( ! empty( $redirect_url ) ) {
|
| 1016 |
+
$redirect_url = ( wppb_check_missing_http( $redirect_url ) ? 'http://'. $redirect_url : $redirect_url );
|
| 1017 |
+
|
| 1018 |
+
if( $redirect_delay == 0 ) {
|
| 1019 |
+
$redirect_message = '<meta http-equiv="Refresh" content="'. $redirect_delay .';url='. $redirect_url .'" />';
|
| 1020 |
+
} else {
|
| 1021 |
+
$redirect_url_href = apply_filters( 'wppb_redirect_url', '<a href="'. $redirect_url .'">'. __( 'here', 'profile-builder' ) .'</a>', $redirect_url, $redirect_type, $form_args );
|
| 1022 |
+
$redirect_message = apply_filters( 'wppb_redirect_message_before_returning', '<p class="redirect_message">'. sprintf( wp_slash( __( 'You will soon be redirected automatically. If you see this page for more than %1$d seconds, please click %2$s.%3$s', 'profile-builder' ) ), $redirect_delay, $redirect_url_href, '<meta http-equiv="Refresh" content="'. $redirect_delay .';url='. $redirect_url .'" />' ) .'</p>', $redirect_url, $redirect_delay, $redirect_url_href, $redirect_type, $form_args );
|
| 1023 |
+
}
|
| 1024 |
+
}
|
| 1025 |
+
|
| 1026 |
+
return $redirect_message;
|
| 1027 |
+
}
|
front-end/class-formbuilder.php
CHANGED
|
@@ -6,6 +6,7 @@ class Profile_Builder_Form_Creator{
|
|
| 6 |
'form_name' => '',
|
| 7 |
'role' => '', //used only for the register-form settings
|
| 8 |
'redirect_url' => '',
|
|
|
|
| 9 |
'redirect_priority' => 'normal',
|
| 10 |
'ID' => null
|
| 11 |
);
|
|
@@ -81,11 +82,8 @@ class Profile_Builder_Form_Creator{
|
|
| 81 |
function wppb_retrieve_custom_settings(){
|
| 82 |
$this->args['login_after_register'] = apply_filters( 'wppb_automatically_login_after_register', 'No' ); //used only for the register-form settings
|
| 83 |
$this->args['redirect_activated'] = apply_filters( 'wppb_redirect_default_setting', '-' );
|
| 84 |
-
$this->args['redirect_url'] = apply_filters( 'wppb_redirect_default_location', ($this->args['redirect_url'] != '') ? $this->args['redirect_url'] :
|
| 85 |
-
|
| 86 |
-
$this->wppb_custom_redirect_check();
|
| 87 |
-
|
| 88 |
-
$this->args['redirect_url'] = apply_filters( 'wppb_after_'.$this->args['form_type'].'_redirect_url', $this->args['redirect_url'] );
|
| 89 |
$this->args['redirect_delay'] = apply_filters( 'wppb_redirect_default_duration', 3 );
|
| 90 |
|
| 91 |
if ( !is_null( $this->args['ID'] ) ){
|
|
@@ -104,12 +102,8 @@ class Profile_Builder_Form_Creator{
|
|
| 104 |
$this->args['role'] = ( isset( $selected_role ) ? $selected_role : $this->args['role'] );
|
| 105 |
$this->args['login_after_register'] = ( isset( $page_settings[0]['automatically-log-in'] ) ? $page_settings[0]['automatically-log-in'] : $this->args['login_after_register'] );
|
| 106 |
$this->args['redirect_activated'] = ( isset( $page_settings[0]['redirect'] ) ? $page_settings[0]['redirect'] : $this->args['redirect_activated'] );
|
| 107 |
-
$this->args['redirect_url'] = ( !empty( $page_settings[0]['url'] ) && $this->args['redirect_activated'] == 'Yes' ? $page_settings[0]['url'] : $this->args['redirect_url'] );
|
| 108 |
-
$this->args['redirect_delay'] = ( isset( $page_settings[0]['display-messages'] ) ? $page_settings[0]['display-messages'] : $this->args['redirect_delay'] );
|
| 109 |
-
|
| 110 |
-
if( $this->args['redirect_activated'] == '-' ) {
|
| 111 |
-
$this->wppb_custom_redirect_check();
|
| 112 |
-
}
|
| 113 |
}
|
| 114 |
|
| 115 |
if( !empty( $this->args['role'] ) ){
|
|
@@ -123,35 +117,6 @@ class Profile_Builder_Form_Creator{
|
|
| 123 |
}
|
| 124 |
}
|
| 125 |
|
| 126 |
-
function wppb_custom_redirect_check() {
|
| 127 |
-
if( PROFILE_BUILDER == 'Profile Builder Pro' ) {
|
| 128 |
-
if( ( $this->args['form_type'] == 'register' || $this->args['form_type'] == 'edit_profile' ) && ( ! current_user_can( 'manage_options' ) ) ) {
|
| 129 |
-
$wppb_module_settings = get_option( 'wppb_module_settings' );
|
| 130 |
-
|
| 131 |
-
if( isset( $_POST['username'] ) )
|
| 132 |
-
$username = $_POST['username'];
|
| 133 |
-
else
|
| 134 |
-
$username = null;
|
| 135 |
-
|
| 136 |
-
if( isset( $wppb_module_settings['wppb_customRedirect'] ) && $wppb_module_settings['wppb_customRedirect'] == 'show' && $this->args['redirect_priority'] != 'top' && function_exists( 'wppb_custom_redirect_url' ) ) {
|
| 137 |
-
if( $this->args['form_type'] == 'register' ) {
|
| 138 |
-
$this->args['redirect_url'] = wppb_custom_redirect_url( 'after_registration', $this->args['redirect_url'], $username, $this->args['role'] );
|
| 139 |
-
|
| 140 |
-
if( $this->args['redirect_activated'] == 'Yes' ) {
|
| 141 |
-
$this->args['custom_redirect_after_register_url'] = $this->args['redirect_url'];
|
| 142 |
-
}
|
| 143 |
-
} else if( $this->args['form_type'] == 'edit_profile' ) {
|
| 144 |
-
$this->args['redirect_url'] = $this->args['custom_redirect_after_edit_profile_url'] = wppb_custom_redirect_url( 'after_edit_profile', $this->args['redirect_url'], $username, $this->args['role'] );
|
| 145 |
-
|
| 146 |
-
if( $this->args['redirect_activated'] == 'Yes' ) {
|
| 147 |
-
$this->args['custom_redirect_after_register_url'] = $this->args['redirect_url'];
|
| 148 |
-
}
|
| 149 |
-
}
|
| 150 |
-
}
|
| 151 |
-
}
|
| 152 |
-
}
|
| 153 |
-
}
|
| 154 |
-
|
| 155 |
function wppb_form_logic() {
|
| 156 |
if( $this->args['form_type'] == 'register' ){
|
| 157 |
$registration = apply_filters ( 'wppb_register_setting_override', get_option( 'users_can_register' ) );
|
|
@@ -183,18 +148,15 @@ class Profile_Builder_Form_Creator{
|
|
| 183 |
if ( isset( $wppb_general_settings['loginWith'] ) && ( $wppb_general_settings['loginWith'] == 'email' ) )
|
| 184 |
$display_name = $userdata->data->user_email;
|
| 185 |
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
if( isset( $wppb_module_settings['wppb_customRedirect'] ) && $wppb_module_settings['wppb_customRedirect'] == 'show' && function_exists( 'wppb_custom_redirect_url' ) ) {
|
| 191 |
-
$redirect_after_logout_url = wppb_custom_redirect_url( 'after_logout', $redirect_after_logout_url );
|
| 192 |
-
}
|
| 193 |
-
}
|
| 194 |
-
$redirect_after_logout_url = apply_filters( 'wppb_after_logout_redirect_url', $redirect_after_logout_url );
|
| 195 |
|
| 196 |
-
|
|
|
|
|
|
|
| 197 |
|
|
|
|
| 198 |
}
|
| 199 |
}
|
| 200 |
|
|
@@ -208,103 +170,108 @@ class Profile_Builder_Form_Creator{
|
|
| 208 |
}
|
| 209 |
}
|
| 210 |
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
if ( $this->args['redirect_activated'] == 'No' || ( $this->args['form_type'] == 'edit_profile' && $this->args['form_name'] == 'unspecified' && wppb_curpageurl() == $this->args['redirect_url'] ) || ( $this->args['form_type'] == 'register' && $this->args['form_name'] == 'unspecified' && wppb_curpageurl() == $this->args['redirect_url'] ) )
|
| 215 |
-
return '';
|
| 216 |
-
|
| 217 |
-
/* if we don't have a preference on the form for redirect then if we have a custom redirect "after register redirect" option redirect to that if not don't do anything */
|
| 218 |
-
if ( $this->args['form_type'] == 'register' && $this->args['redirect_activated'] == '-' ){
|
| 219 |
-
if( !empty( $this->args['custom_redirect_after_register_url'] ) )
|
| 220 |
-
$this->args['redirect_url'] = $this->args['custom_redirect_after_register_url'];
|
| 221 |
-
}
|
| 222 |
-
|
| 223 |
-
/* if we don't have a preference on the form for redirect then if we have a custom redirect "after edit profile redirect" option redirect to that if not don't do anything */
|
| 224 |
-
if ( $this->args['form_type'] == 'edit_profile' && $this->args['redirect_activated'] == '-' ){
|
| 225 |
-
if( !empty( $this->args['custom_redirect_after_edit_profile_url'] ) )
|
| 226 |
-
$this->args['redirect_url'] = $this->args['custom_redirect_after_edit_profile_url'];
|
| 227 |
-
}
|
| 228 |
-
|
| 229 |
-
$redirect_location = ( wppb_check_missing_http( $this->args['redirect_url'] ) ? 'http://'.$this->args['redirect_url'] : $this->args['redirect_url'] );
|
| 230 |
-
$redirect_url = apply_filters( 'wppb_redirect_url', '<a href="'.$redirect_location.'">'.__( 'here', 'profile-builder' ).'</a>' );
|
| 231 |
-
|
| 232 |
-
return apply_filters ( 'wppb_redirect_message_before_returning', '<p class="redirect_message">'.sprintf( wp_slash( __( 'You will soon be redirected automatically. If you see this page for more than %1$d seconds, please click %2$s.%3$s', 'profile-builder' ) ), $this->args['redirect_delay'], $redirect_url, '<meta http-equiv="Refresh" content="'.$this->args['redirect_delay'].';url='.$redirect_location.'" />' ).'</p>', $this->args );
|
| 233 |
-
}
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
function wppb_log_in_user(){
|
| 237 |
-
if ( is_user_logged_in() )
|
| 238 |
return;
|
|
|
|
| 239 |
|
| 240 |
$wppb_general_settings = get_option( 'wppb_general_settings' );
|
| 241 |
-
if ( isset( $wppb_general_settings['emailConfirmation'] ) && ( $wppb_general_settings['emailConfirmation'] == 'yes' ) )
|
| 242 |
-
return;
|
| 243 |
|
| 244 |
-
if ( isset( $wppb_general_settings['
|
| 245 |
-
return;
|
|
|
|
| 246 |
|
| 247 |
-
if(
|
| 248 |
-
|
| 249 |
-
|
| 250 |
|
| 251 |
/* get user id */
|
| 252 |
$user = get_user_by( 'email', trim( $_POST['email'] ) );
|
| 253 |
-
$nonce = wp_create_nonce( 'autologin-'
|
| 254 |
|
| 255 |
/* define redirect location */
|
| 256 |
-
if
|
| 257 |
-
if
|
| 258 |
-
|
| 259 |
} else {
|
| 260 |
-
|
| 261 |
}
|
| 262 |
-
}else if ( $this->args['redirect_activated'] == '-' ){
|
| 263 |
-
$this->wppb_custom_redirect_check();
|
| 264 |
-
$location = $this->args['redirect_url'];
|
| 265 |
}
|
| 266 |
-
else{
|
| 267 |
-
$location = ( wppb_check_missing_http( $this->args['redirect_url'] ) ? 'http://'.$this->args['redirect_url'] : $this->args['redirect_url'] );
|
| 268 |
-
}
|
| 269 |
-
|
| 270 |
-
$location = apply_filters('wppb_login_after_reg_redirect_url', $location, $this);
|
| 271 |
-
|
| 272 |
-
if( function_exists( 'wppb_cr_replace_tags' ) )
|
| 273 |
-
$location = wppb_cr_replace_tags( $location );
|
| 274 |
|
| 275 |
-
$
|
| 276 |
|
| 277 |
-
|
| 278 |
|
| 279 |
-
|
| 280 |
-
|
|
|
|
| 281 |
} else {
|
| 282 |
-
|
| 283 |
}
|
|
|
|
| 284 |
}
|
| 285 |
-
|
| 286 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
$field_check_errors = array();
|
| 288 |
|
| 289 |
-
if( isset( $_REQUEST['action'] ) ){
|
| 290 |
$field_check_errors = $this->wppb_test_required_form_values( $_REQUEST );
|
| 291 |
-
if( empty( $field_check_errors ) ){
|
| 292 |
|
| 293 |
-
do_action('wppb_before_saving_form_values',$_REQUEST, $this->args);
|
| 294 |
|
| 295 |
// we only have a $user_id on default registration (no email confirmation, no multisite)
|
| 296 |
$user_id = $this->wppb_save_form_values( $_REQUEST );
|
| 297 |
-
|
| 298 |
-
if ( ( 'POST' == $_SERVER['REQUEST_METHOD'] ) && ( $_POST['action'] == $this->args['form_type'] ) ){
|
| 299 |
|
| 300 |
-
|
| 301 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 302 |
|
| 303 |
-
if( $this->args['form_type'] == 'register' ){
|
| 304 |
// ec = email confirmation setting
|
| 305 |
// aa = admin approval setting
|
| 306 |
$wppb_general_settings = get_option( 'wppb_general_settings', 'false' );
|
| 307 |
-
if ( $wppb_general_settings ){
|
| 308 |
if( !empty( $wppb_general_settings['emailConfirmation'] ) )
|
| 309 |
$wppb_email_confirmation = $wppb_general_settings['emailConfirmation'];
|
| 310 |
else
|
|
@@ -319,13 +286,7 @@ class Profile_Builder_Form_Creator{
|
|
| 319 |
$account_management_settings = 'ec-no_aa-no';
|
| 320 |
}
|
| 321 |
|
| 322 |
-
|
| 323 |
-
$account_name = trim( $_POST['username'] );
|
| 324 |
-
} elseif( isset( $_POST['email'] ) && ( trim( $_POST['email'] ) != '' ) ) {
|
| 325 |
-
$account_name = trim( $_POST['email'] );
|
| 326 |
-
}
|
| 327 |
-
|
| 328 |
-
switch ( $account_management_settings ){
|
| 329 |
case 'ec-no_aa-no':
|
| 330 |
$wppb_register_success_message = apply_filters( 'wppb_register_success_message', sprintf( __( "The account %1s has been successfully created!", 'profile-builder' ), $account_name ), $account_name );
|
| 331 |
break;
|
|
@@ -343,17 +304,27 @@ class Profile_Builder_Form_Creator{
|
|
| 343 |
$wppb_register_success_message = apply_filters( 'wppb_register_success_message', sprintf( __( "Before you can access your account %1s, you need to confirm your email address. Please check your inbox and click the activation link.", 'profile-builder' ), $account_name ), $account_name );
|
| 344 |
break;
|
| 345 |
}
|
| 346 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 347 |
echo $form_message_tpl_start . $wppb_register_success_message . $form_message_tpl_end . $redirect;
|
| 348 |
//action hook after registration success
|
| 349 |
-
do_action('wppb_register_success', $_REQUEST, $this->args['form_name'], $user_id);
|
| 350 |
return;
|
| 351 |
-
} elseif
|
| 352 |
-
|
|
|
|
|
|
|
| 353 |
echo $form_message_tpl_start . apply_filters( 'wppb_edit_profile_success_message', __( 'Your profile has been successfully updated!', 'profile-builder' ) ) . $form_message_tpl_end . $redirect;
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
|
|
|
| 357 |
return;
|
| 358 |
}
|
| 359 |
|
|
@@ -586,10 +557,6 @@ class Profile_Builder_Form_Creator{
|
|
| 586 |
|
| 587 |
if( ! isset( $userdata['role'] ) ) {
|
| 588 |
$userdata['role'] = $this->args['role'];
|
| 589 |
-
} else {
|
| 590 |
-
if( isset( $wppb_module_settings['wppb_customRedirect'] ) && $wppb_module_settings['wppb_customRedirect'] == 'show' && function_exists( 'wppb_custom_redirect_url' ) ) {
|
| 591 |
-
$this->args['redirect_url'] = wppb_custom_redirect_url( 'after_registration', $this->args['redirect_url'], $userdata["user_login"], $userdata['role'] );
|
| 592 |
-
}
|
| 593 |
}
|
| 594 |
|
| 595 |
$userdata['user_pass'] = wp_hash_password( $userdata['user_pass'] );
|
|
@@ -601,14 +568,9 @@ class Profile_Builder_Form_Creator{
|
|
| 601 |
}
|
| 602 |
|
| 603 |
wppb_signup_user( $userdata['user_login'], $userdata['user_email'], $userdata );
|
| 604 |
-
|
| 605 |
}else{
|
| 606 |
if( ! isset( $userdata['role'] ) ) {
|
| 607 |
$userdata['role'] = $this->args['role'];
|
| 608 |
-
} else {
|
| 609 |
-
if( isset( $wppb_module_settings['wppb_customRedirect'] ) && $wppb_module_settings['wppb_customRedirect'] == 'show' && function_exists( 'wppb_custom_redirect_url' ) ) {
|
| 610 |
-
$this->args['redirect_url'] = wppb_custom_redirect_url( 'after_registration', $this->args['redirect_url'], $userdata["user_login"], $userdata['role'] );
|
| 611 |
-
}
|
| 612 |
}
|
| 613 |
|
| 614 |
$userdata = wp_unslash( $userdata );
|
| 6 |
'form_name' => '',
|
| 7 |
'role' => '', //used only for the register-form settings
|
| 8 |
'redirect_url' => '',
|
| 9 |
+
'logout_redirect_url' => '', //used only for the register-form settings
|
| 10 |
'redirect_priority' => 'normal',
|
| 11 |
'ID' => null
|
| 12 |
);
|
| 82 |
function wppb_retrieve_custom_settings(){
|
| 83 |
$this->args['login_after_register'] = apply_filters( 'wppb_automatically_login_after_register', 'No' ); //used only for the register-form settings
|
| 84 |
$this->args['redirect_activated'] = apply_filters( 'wppb_redirect_default_setting', '-' );
|
| 85 |
+
$this->args['redirect_url'] = apply_filters( 'wppb_redirect_default_location', ( $this->args['redirect_url'] != '' ) ? $this->args['redirect_url'] : '' );
|
| 86 |
+
$this->args['logout_redirect_url'] = apply_filters( 'wppb_logout_redirect_default_location', ( $this->args['logout_redirect_url'] != '' ) ? $this->args['logout_redirect_url'] : '' );
|
|
|
|
|
|
|
|
|
|
| 87 |
$this->args['redirect_delay'] = apply_filters( 'wppb_redirect_default_duration', 3 );
|
| 88 |
|
| 89 |
if ( !is_null( $this->args['ID'] ) ){
|
| 102 |
$this->args['role'] = ( isset( $selected_role ) ? $selected_role : $this->args['role'] );
|
| 103 |
$this->args['login_after_register'] = ( isset( $page_settings[0]['automatically-log-in'] ) ? $page_settings[0]['automatically-log-in'] : $this->args['login_after_register'] );
|
| 104 |
$this->args['redirect_activated'] = ( isset( $page_settings[0]['redirect'] ) ? $page_settings[0]['redirect'] : $this->args['redirect_activated'] );
|
| 105 |
+
$this->args['redirect_url'] = ( ! empty( $page_settings[0]['url'] ) && $this->args['redirect_activated'] == 'Yes' && $this->args['redirect_priority'] != 'top' ? $page_settings[0]['url'] : $this->args['redirect_url'] );
|
| 106 |
+
$this->args['redirect_delay'] = ( isset( $page_settings[0]['display-messages'] ) && $this->args['redirect_activated'] == 'Yes' ? $page_settings[0]['display-messages'] : $this->args['redirect_delay'] );
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
}
|
| 108 |
|
| 109 |
if( !empty( $this->args['role'] ) ){
|
| 117 |
}
|
| 118 |
}
|
| 119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
function wppb_form_logic() {
|
| 121 |
if( $this->args['form_type'] == 'register' ){
|
| 122 |
$registration = apply_filters ( 'wppb_register_setting_override', get_option( 'users_can_register' ) );
|
| 148 |
if ( isset( $wppb_general_settings['loginWith'] ) && ( $wppb_general_settings['loginWith'] == 'email' ) )
|
| 149 |
$display_name = $userdata->data->user_email;
|
| 150 |
|
| 151 |
+
if( empty( $this->args['logout_redirect_url'] ) ) {
|
| 152 |
+
$this->args['logout_redirect_url'] = get_permalink();
|
| 153 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
|
| 155 |
+
// CHECK FOR REDIRECT
|
| 156 |
+
$this->args['logout_redirect_url'] = wppb_get_redirect_url( $this->args['redirect_priority'], 'after_logout', $this->args['logout_redirect_url'], $userdata );
|
| 157 |
+
$this->args['logout_redirect_url'] = apply_filters( 'wppb_after_logout_redirect_url', $this->args['logout_redirect_url'] );
|
| 158 |
|
| 159 |
+
echo apply_filters( 'wppb_register_pre_form_message', '<p class="alert" id="wppb_register_pre_form_message">'.sprintf( __( "You are currently logged in as %1s. You don't need another account. %2s", 'profile-builder' ), '<a href="'.get_author_posts_url( $user_ID ).'" title="'.$display_name.'">'.$display_name.'</a>', '<a href="'.wp_logout_url( $this->args['logout_redirect_url'] ).'" title="'.__( 'Log out of this account.', 'profile-builder' ).'">'.__( 'Logout', 'profile-builder' ).' »</a>' ).'</p>', $user_ID );
|
| 160 |
}
|
| 161 |
}
|
| 162 |
|
| 170 |
}
|
| 171 |
}
|
| 172 |
|
| 173 |
+
// Function used to automatically log in a user after register if that option is set on yes in register form settings
|
| 174 |
+
function wppb_log_in_user( $redirect, $redirect_old ) {
|
| 175 |
+
if( is_user_logged_in() ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
return;
|
| 177 |
+
}
|
| 178 |
|
| 179 |
$wppb_general_settings = get_option( 'wppb_general_settings' );
|
|
|
|
|
|
|
| 180 |
|
| 181 |
+
if ( isset( $wppb_general_settings['emailConfirmation'] ) && ( $wppb_general_settings['emailConfirmation'] == 'yes' ) ) {
|
| 182 |
+
return $redirect_old;
|
| 183 |
+
}
|
| 184 |
|
| 185 |
+
if ( isset( $wppb_general_settings['adminApproval'] ) && ( $wppb_general_settings['adminApproval'] == 'yes' ) ) {
|
| 186 |
+
return $redirect_old;
|
| 187 |
+
}
|
| 188 |
|
| 189 |
/* get user id */
|
| 190 |
$user = get_user_by( 'email', trim( $_POST['email'] ) );
|
| 191 |
+
$nonce = wp_create_nonce( 'autologin-'. $user->ID .'-'. (int)( time() / 60 ) );
|
| 192 |
|
| 193 |
/* define redirect location */
|
| 194 |
+
if( $this->args['redirect_activated'] == 'No' ) {
|
| 195 |
+
if( isset( $_POST['_wp_http_referer'] ) ) {
|
| 196 |
+
$redirect = $_POST['_wp_http_referer'];
|
| 197 |
} else {
|
| 198 |
+
$redirect = home_url();
|
| 199 |
}
|
|
|
|
|
|
|
|
|
|
| 200 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
|
| 202 |
+
$redirect = apply_filters( 'wppb_login_after_reg_redirect_url', $redirect, $this );
|
| 203 |
|
| 204 |
+
$redirect = add_query_arg( array( 'autologin' => 'true', 'uid' => $user->ID, '_wpnonce' => $nonce ), $redirect );
|
| 205 |
|
| 206 |
+
// CHECK FOR REDIRECT
|
| 207 |
+
if( $this->args['redirect_activated'] == 'No' || ( empty( $this->args['redirect_delay'] ) || $this->args['redirect_delay'] == '0' ) ) {
|
| 208 |
+
$redirect = wppb_build_redirect( $redirect, 0, 'register', $this->args );
|
| 209 |
} else {
|
| 210 |
+
$redirect = wppb_build_redirect( $redirect, $this->args['redirect_delay'], 'register', $this->args );
|
| 211 |
}
|
| 212 |
+
return $redirect;
|
| 213 |
}
|
| 214 |
+
|
| 215 |
+
/**
|
| 216 |
+
* Function to get redirect for Register and Edit Profile forms
|
| 217 |
+
*
|
| 218 |
+
* @param string $form_type - type of the form
|
| 219 |
+
* @param string $redirect_type - type of the redirect
|
| 220 |
+
* @param string $user - username or user email
|
| 221 |
+
* @param string $user_role - user Role
|
| 222 |
+
*
|
| 223 |
+
* @return string $redirect
|
| 224 |
+
*/
|
| 225 |
+
function wppb_get_redirect( $form_type, $redirect_type, $user, $user_role ) {
|
| 226 |
+
$this->args['redirect_delay'] = apply_filters( 'wppb_'. $form_type .'_redirect_delay', $this->args['redirect_delay'], $user, $this->args );
|
| 227 |
+
if( $this->args['redirect_activated'] == '-' ) {
|
| 228 |
+
$this->args['redirect_url'] = wppb_get_redirect_url( $this->args['redirect_priority'], $redirect_type, $this->args['redirect_url'], $user, $user_role );
|
| 229 |
+
$redirect = wppb_build_redirect( $this->args['redirect_url'], $this->args['redirect_delay'], $form_type, $this->args );
|
| 230 |
+
} elseif( $this->args['redirect_activated'] == 'Yes' ) {
|
| 231 |
+
$redirect = wppb_build_redirect( $this->args['redirect_url'], $this->args['redirect_delay'], $form_type, $this->args );
|
| 232 |
+
} else {
|
| 233 |
+
$redirect = '';
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
return $redirect;
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
function wppb_form_content( $message ) {
|
| 240 |
$field_check_errors = array();
|
| 241 |
|
| 242 |
+
if( isset( $_REQUEST['action'] ) ) {
|
| 243 |
$field_check_errors = $this->wppb_test_required_form_values( $_REQUEST );
|
| 244 |
+
if( empty( $field_check_errors ) ) {
|
| 245 |
|
| 246 |
+
do_action( 'wppb_before_saving_form_values',$_REQUEST, $this->args );
|
| 247 |
|
| 248 |
// we only have a $user_id on default registration (no email confirmation, no multisite)
|
| 249 |
$user_id = $this->wppb_save_form_values( $_REQUEST );
|
|
|
|
|
|
|
| 250 |
|
| 251 |
+
if( ( 'POST' == $_SERVER['REQUEST_METHOD'] ) && ( $_POST['action'] == $this->args['form_type'] ) ) {
|
| 252 |
+
|
| 253 |
+
$form_message_tpl_start = apply_filters( 'wppb_form_message_tpl_start', '<p class="alert" id="wppb_form_success_message">' );
|
| 254 |
+
$form_message_tpl_end = apply_filters( 'wppb_form_message_tpl_end', '</p>' );
|
| 255 |
+
|
| 256 |
+
if( isset( $_POST['custom_field_user_role'] ) ) {
|
| 257 |
+
$user_role = $_POST['custom_field_user_role'];
|
| 258 |
+
} elseif( isset( $this->args['role'] ) ) {
|
| 259 |
+
$user_role = $this->args['role'];
|
| 260 |
+
} else {
|
| 261 |
+
$user_role = NULL;
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
if( isset( $_POST['username'] ) && ( trim( $_POST['username'] ) != '' ) ) {
|
| 265 |
+
$account_name = trim( $_POST['username'] );
|
| 266 |
+
} elseif( isset( $_POST['email'] ) && ( trim( $_POST['email'] ) != '' ) ) {
|
| 267 |
+
$account_name = trim( $_POST['email'] );
|
| 268 |
+
}
|
| 269 |
|
| 270 |
+
if( $this->args['form_type'] == 'register' ) {
|
| 271 |
// ec = email confirmation setting
|
| 272 |
// aa = admin approval setting
|
| 273 |
$wppb_general_settings = get_option( 'wppb_general_settings', 'false' );
|
| 274 |
+
if ( $wppb_general_settings ) {
|
| 275 |
if( !empty( $wppb_general_settings['emailConfirmation'] ) )
|
| 276 |
$wppb_email_confirmation = $wppb_general_settings['emailConfirmation'];
|
| 277 |
else
|
| 286 |
$account_management_settings = 'ec-no_aa-no';
|
| 287 |
}
|
| 288 |
|
| 289 |
+
switch( $account_management_settings ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
case 'ec-no_aa-no':
|
| 291 |
$wppb_register_success_message = apply_filters( 'wppb_register_success_message', sprintf( __( "The account %1s has been successfully created!", 'profile-builder' ), $account_name ), $account_name );
|
| 292 |
break;
|
| 304 |
$wppb_register_success_message = apply_filters( 'wppb_register_success_message', sprintf( __( "Before you can access your account %1s, you need to confirm your email address. Please check your inbox and click the activation link.", 'profile-builder' ), $account_name ), $account_name );
|
| 305 |
break;
|
| 306 |
}
|
| 307 |
+
|
| 308 |
+
// CHECK FOR REDIRECT
|
| 309 |
+
$redirect = $this->wppb_get_redirect( 'register', 'after_registration', $account_name, $user_role );
|
| 310 |
+
|
| 311 |
+
if( $this->args['login_after_register'] == 'Yes' ) {
|
| 312 |
+
$redirect = $this->wppb_log_in_user( $this->args['redirect_url'], $redirect );
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
echo $form_message_tpl_start . $wppb_register_success_message . $form_message_tpl_end . $redirect;
|
| 316 |
//action hook after registration success
|
| 317 |
+
do_action( 'wppb_register_success', $_REQUEST, $this->args['form_name'], $user_id );
|
| 318 |
return;
|
| 319 |
+
} elseif( $this->args['form_type'] == 'edit_profile' ) {
|
| 320 |
+
// CHECK FOR REDIRECT
|
| 321 |
+
$redirect = $this->wppb_get_redirect( 'edit_profile', 'after_edit_profile', $account_name, $user_role );
|
| 322 |
+
|
| 323 |
echo $form_message_tpl_start . apply_filters( 'wppb_edit_profile_success_message', __( 'Your profile has been successfully updated!', 'profile-builder' ) ) . $form_message_tpl_end . $redirect;
|
| 324 |
+
|
| 325 |
+
//action hook after edit profile success
|
| 326 |
+
do_action( 'wppb_edit_profile_success', $_REQUEST, $this->args['form_name'], $user_id );
|
| 327 |
+
if( apply_filters( 'wppb_no_form_after_profile_update', false ) )
|
| 328 |
return;
|
| 329 |
}
|
| 330 |
|
| 557 |
|
| 558 |
if( ! isset( $userdata['role'] ) ) {
|
| 559 |
$userdata['role'] = $this->args['role'];
|
|
|
|
|
|
|
|
|
|
|
|
|
| 560 |
}
|
| 561 |
|
| 562 |
$userdata['user_pass'] = wp_hash_password( $userdata['user_pass'] );
|
| 568 |
}
|
| 569 |
|
| 570 |
wppb_signup_user( $userdata['user_login'], $userdata['user_email'], $userdata );
|
|
|
|
| 571 |
}else{
|
| 572 |
if( ! isset( $userdata['role'] ) ) {
|
| 573 |
$userdata['role'] = $this->args['role'];
|
|
|
|
|
|
|
|
|
|
|
|
|
| 574 |
}
|
| 575 |
|
| 576 |
$userdata = wp_unslash( $userdata );
|
front-end/edit-profile.php
CHANGED
|
@@ -66,15 +66,6 @@ function wppb_front_end_profile_info( $atts ){
|
|
| 66 |
// get value set in the shortcode as parameter, still need to default to something else than empty string
|
| 67 |
extract( shortcode_atts( array( 'form_name' => 'unspecified', 'redirect_url' => '', 'redirect_priority' => 'normal' ), $atts, 'wppb-edit-profile' ) );
|
| 68 |
|
| 69 |
-
if( PROFILE_BUILDER == 'Profile Builder Pro' ) {
|
| 70 |
-
$wppb_module_settings = get_option( 'wppb_module_settings' );
|
| 71 |
-
|
| 72 |
-
if( isset( $wppb_module_settings['wppb_customRedirect'] ) && $wppb_module_settings['wppb_customRedirect'] == 'show' && $redirect_priority != 'top' && function_exists( 'wppb_custom_redirect_url' ) ) {
|
| 73 |
-
$redirect_url = wppb_custom_redirect_url( 'after_edit_profile', $redirect_url );
|
| 74 |
-
}
|
| 75 |
-
}
|
| 76 |
-
$redirect_url = apply_filters( 'wppb_after_edit_profile_redirect_url', $redirect_url );
|
| 77 |
-
|
| 78 |
global ${$form_name};
|
| 79 |
|
| 80 |
$$form_name = new Profile_Builder_Form_Creator( array( 'form_type' => 'edit_profile', 'form_name' => $form_name, 'redirect_url' => $redirect_url, 'redirect_priority' => $redirect_priority ) );
|
| 66 |
// get value set in the shortcode as parameter, still need to default to something else than empty string
|
| 67 |
extract( shortcode_atts( array( 'form_name' => 'unspecified', 'redirect_url' => '', 'redirect_priority' => 'normal' ), $atts, 'wppb-edit-profile' ) );
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
global ${$form_name};
|
| 70 |
|
| 71 |
$$form_name = new Profile_Builder_Form_Creator( array( 'form_type' => 'edit_profile', 'form_name' => $form_name, 'redirect_url' => $redirect_url, 'redirect_priority' => $redirect_priority ) );
|
front-end/login.php
CHANGED
|
@@ -110,9 +110,9 @@ if( isset( $wppb_generalSettings['loginWith'] ) && ( $wppb_generalSettings['logi
|
|
| 110 |
}
|
| 111 |
|
| 112 |
// login redirect filter. used to redirect from wp-login.php if it errors out
|
| 113 |
-
function wppb_login_redirect( $redirect_to, $
|
| 114 |
// if login action initialized by our form
|
| 115 |
-
|
| 116 |
if( is_wp_error( $user ) ) {
|
| 117 |
// if we don't have a successful login we must redirect to the url of the form, so make sure this happens
|
| 118 |
$redirect_to = $_POST['wppb_request_url'];
|
|
@@ -170,18 +170,8 @@ function wppb_login_redirect( $redirect_to, $redirect_url, $user ){
|
|
| 170 |
// we don't have an error make sure to remove the error from the query arg
|
| 171 |
$redirect_to = remove_query_arg( 'loginerror', $redirect_to );
|
| 172 |
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
$wppb_module_settings = get_option( 'wppb_module_settings' );
|
| 176 |
-
|
| 177 |
-
if( isset( $wppb_module_settings['wppb_customRedirect'] ) && $wppb_module_settings['wppb_customRedirect'] == 'show' && $_POST['wppb_redirect_priority'] != 'top' && function_exists( 'wppb_custom_redirect_url' ) ) {
|
| 178 |
-
$redirect_url = wppb_custom_redirect_url( 'after_login', $redirect_to, $user );
|
| 179 |
-
|
| 180 |
-
if( ! empty( $redirect_url ) ) {
|
| 181 |
-
$redirect_to = $redirect_url;
|
| 182 |
-
}
|
| 183 |
-
}
|
| 184 |
-
}
|
| 185 |
$redirect_to = apply_filters( 'wppb_after_login_redirect_url', $redirect_to );
|
| 186 |
}
|
| 187 |
}
|
|
@@ -194,7 +184,7 @@ add_filter( 'login_redirect', 'wppb_login_redirect', 10, 3 );
|
|
| 194 |
/* shortcode function */
|
| 195 |
function wppb_front_end_login( $atts ){
|
| 196 |
|
| 197 |
-
extract( shortcode_atts( array( 'display' => true, 'redirect' => '', 'redirect_url' => '', 'register_url' => '', 'lostpassword_url' => '', 'redirect_priority' => 'normal' ), $atts ) );
|
| 198 |
|
| 199 |
$wppb_generalSettings = get_option('wppb_general_settings');
|
| 200 |
|
|
@@ -208,11 +198,11 @@ function wppb_front_end_login( $atts ){
|
|
| 208 |
}
|
| 209 |
|
| 210 |
if ( ! empty( $redirect_url ) ) {
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
|
| 217 |
$form_args['redirect'] = trim( $redirect_url );
|
| 218 |
}
|
|
@@ -230,7 +220,7 @@ function wppb_front_end_login( $atts ){
|
|
| 230 |
|
| 231 |
// initialize our form variable
|
| 232 |
$login_form = '';
|
| 233 |
-
|
| 234 |
// display our login errors
|
| 235 |
if( isset( $_GET['loginerror'] ) || isset( $_POST['loginerror'] ) ){
|
| 236 |
$loginerror = isset( $_GET['loginerror'] ) ? $_GET['loginerror'] : $_POST['loginerror'];
|
|
@@ -295,21 +285,15 @@ function wppb_front_end_login( $atts ){
|
|
| 295 |
|
| 296 |
$logged_in_message = '<p class="wppb-alert">';
|
| 297 |
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
|
| 302 |
-
|
| 303 |
-
$redirect_after_logout_url = wppb_custom_redirect_url( 'after_logout', $redirect_after_logout_url );
|
| 304 |
-
}
|
| 305 |
-
}
|
| 306 |
-
$redirect_after_logout_url = apply_filters( 'wppb_after_logout_redirect_url', $redirect_after_logout_url );
|
| 307 |
-
$logout_url = '<a href="'.wp_logout_url( $redirect_after_logout_url ).'" class="wppb-logout-url" title="'.__( 'Log out of this account', 'profile-builder' ).'">'. __( 'Log out', 'profile-builder').' »</a>';
|
| 308 |
$logged_in_message .= sprintf(__( 'You are currently logged in as %1$s. %2$s', 'profile-builder' ), $display_name, $logout_url );
|
| 309 |
|
| 310 |
$logged_in_message .= '</p><!-- .wppb-alert-->';
|
| 311 |
|
| 312 |
return apply_filters( 'wppb_login_message', $logged_in_message, $wppb_user->ID, $display_name );
|
| 313 |
-
|
| 314 |
}
|
| 315 |
}
|
| 110 |
}
|
| 111 |
|
| 112 |
// login redirect filter. used to redirect from wp-login.php if it errors out
|
| 113 |
+
function wppb_login_redirect( $redirect_to, $requested_redirect_to, $user ){
|
| 114 |
// if login action initialized by our form
|
| 115 |
+
if( isset( $_POST['wppb_login'] ) ){
|
| 116 |
if( is_wp_error( $user ) ) {
|
| 117 |
// if we don't have a successful login we must redirect to the url of the form, so make sure this happens
|
| 118 |
$redirect_to = $_POST['wppb_request_url'];
|
| 170 |
// we don't have an error make sure to remove the error from the query arg
|
| 171 |
$redirect_to = remove_query_arg( 'loginerror', $redirect_to );
|
| 172 |
|
| 173 |
+
// CHECK FOR REDIRECT
|
| 174 |
+
$redirect_to = wppb_get_redirect_url( $_POST['wppb_redirect_priority'], 'after_login', $redirect_to, $user );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
$redirect_to = apply_filters( 'wppb_after_login_redirect_url', $redirect_to );
|
| 176 |
}
|
| 177 |
}
|
| 184 |
/* shortcode function */
|
| 185 |
function wppb_front_end_login( $atts ){
|
| 186 |
|
| 187 |
+
extract( shortcode_atts( array( 'display' => true, 'redirect' => '', 'redirect_url' => '', 'logout_redirect_url' => wppb_curpageurl(), 'register_url' => '', 'lostpassword_url' => '', 'redirect_priority' => 'normal' ), $atts ) );
|
| 188 |
|
| 189 |
$wppb_generalSettings = get_option('wppb_general_settings');
|
| 190 |
|
| 198 |
}
|
| 199 |
|
| 200 |
if ( ! empty( $redirect_url ) ) {
|
| 201 |
+
if( $redirect_priority == 'top' ) {
|
| 202 |
+
$form_args['redirect_priority'] = 'top';
|
| 203 |
+
} else {
|
| 204 |
+
$form_args['redirect_priority'] = 'normal';
|
| 205 |
+
}
|
| 206 |
|
| 207 |
$form_args['redirect'] = trim( $redirect_url );
|
| 208 |
}
|
| 220 |
|
| 221 |
// initialize our form variable
|
| 222 |
$login_form = '';
|
| 223 |
+
|
| 224 |
// display our login errors
|
| 225 |
if( isset( $_GET['loginerror'] ) || isset( $_POST['loginerror'] ) ){
|
| 226 |
$loginerror = isset( $_GET['loginerror'] ) ? $_GET['loginerror'] : $_POST['loginerror'];
|
| 285 |
|
| 286 |
$logged_in_message = '<p class="wppb-alert">';
|
| 287 |
|
| 288 |
+
// CHECK FOR REDIRECT
|
| 289 |
+
$logout_redirect_url = wppb_get_redirect_url( $redirect_priority, 'after_logout', $logout_redirect_url, $wppb_user );
|
| 290 |
+
$logout_redirect_url = apply_filters( 'wppb_after_logout_redirect_url', $logout_redirect_url );
|
| 291 |
|
| 292 |
+
$logout_url = '<a href="'.wp_logout_url( $logout_redirect_url ).'" class="wppb-logout-url" title="'.__( 'Log out of this account', 'profile-builder' ).'">'. __( 'Log out', 'profile-builder').' »</a>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
$logged_in_message .= sprintf(__( 'You are currently logged in as %1$s. %2$s', 'profile-builder' ), $display_name, $logout_url );
|
| 294 |
|
| 295 |
$logged_in_message .= '</p><!-- .wppb-alert-->';
|
| 296 |
|
| 297 |
return apply_filters( 'wppb_login_message', $logged_in_message, $wppb_user->ID, $display_name );
|
|
|
|
| 298 |
}
|
| 299 |
}
|
front-end/logout.php
CHANGED
|
@@ -12,21 +12,17 @@
|
|
| 12 |
|
| 13 |
$current_user = get_userdata( get_current_user_id() );
|
| 14 |
|
| 15 |
-
extract( shortcode_atts( array( 'text' => sprintf( __('You are currently logged in as %s. ','profile-builder') ,$current_user->user_login) , 'redirect' =>
|
| 16 |
|
| 17 |
-
if( !empty( $
|
| 18 |
-
$
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
-
$redirect = wppb_custom_redirect_url( 'after_logout', $redirect );
|
| 25 |
-
}
|
| 26 |
-
}
|
| 27 |
-
$redirect = apply_filters( 'wppb_after_logout_redirect_url', $redirect );
|
| 28 |
-
|
| 29 |
-
$logout_link = '<a href="' . wp_logout_url( $redirect ) . '" class="wppb-logout-url" title="' . __( 'Log out of this account', 'profile-builder' ) . '">' . $link_text . '</a>';
|
| 30 |
|
| 31 |
$meta_tags = apply_filters( 'wppb_front_end_logout_meta_tags', array( '{{meta_user_name}}', '{{meta_first_name}}', '{{meta_last_name}}', '{{meta_display_name}}' ) );
|
| 32 |
$meta_tags_values = apply_filters( 'wppb_front_end_logout_meta_tags_values', array( $current_user->user_login, $current_user->first_name, $current_user->last_name, $current_user->display_name ) );
|
| 12 |
|
| 13 |
$current_user = get_userdata( get_current_user_id() );
|
| 14 |
|
| 15 |
+
extract( shortcode_atts( array( 'text' => sprintf( __('You are currently logged in as %s. ','profile-builder') ,$current_user->user_login) , 'redirect' => '', 'redirect_url' => wppb_curpageurl(), 'redirect_priority' => 'normal', 'link_text' => __('Log out »','profile-builder')), $atts ) );
|
| 16 |
|
| 17 |
+
if( ! empty( $redirect ) ) {
|
| 18 |
+
$redirect_url = $redirect;
|
| 19 |
+
}
|
| 20 |
|
| 21 |
+
// CHECK FOR REDIRECT
|
| 22 |
+
$redirect_url = wppb_get_redirect_url( $redirect_priority, 'after_logout', $redirect_url, $current_user );
|
| 23 |
+
$redirect_url = apply_filters( 'wppb_after_logout_redirect_url', $redirect_url );
|
| 24 |
|
| 25 |
+
$logout_link = '<a href="' . wp_logout_url( $redirect_url ) . '" class="wppb-logout-url" title="' . __( 'Log out of this account', 'profile-builder' ) . '">' . $link_text . '</a>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
$meta_tags = apply_filters( 'wppb_front_end_logout_meta_tags', array( '{{meta_user_name}}', '{{meta_first_name}}', '{{meta_last_name}}', '{{meta_display_name}}' ) );
|
| 28 |
$meta_tags_values = apply_filters( 'wppb_front_end_logout_meta_tags_values', array( $current_user->user_login, $current_user->first_name, $current_user->last_name, $current_user->display_name ) );
|
front-end/recover.php
CHANGED
|
@@ -343,27 +343,15 @@ function wppb_front_end_password_recovery(){
|
|
| 343 |
}
|
| 344 |
}else{
|
| 345 |
if( $messageNo2 == '1' ) {
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
$redirect_url = wppb_custom_redirect_url( 'after_success_password_reset', '', $_GET['loginName'] );
|
| 351 |
-
$redirect_url = apply_filters( 'wppb_after_success_password_reset_redirect_url', $redirect_url );
|
| 352 |
-
|
| 353 |
-
if( isset( $redirect_url ) && ! empty( $redirect_url ) ) {
|
| 354 |
-
$redirect_after_seconds = 3;
|
| 355 |
-
echo apply_filters( 'wppb_after_success_password_reset_redirect_after_seconds', '<meta http-equiv="refresh" content="' . $redirect_after_seconds . '; url=' . $redirect_url . '">', $redirect_after_seconds );
|
| 356 |
-
|
| 357 |
-
$before_redirect_message = 'You will soon be redirected automatically. If you see this page for more than ' . $redirect_after_seconds . ' seconds, please click <a href="' . $redirect_url . '">here</a>.';
|
| 358 |
-
$before_redirect_message = apply_filters( 'wppb_after_success_password_reset_before_redirect_message', $before_redirect_message );
|
| 359 |
-
}
|
| 360 |
-
}
|
| 361 |
-
}
|
| 362 |
|
| 363 |
echo apply_filters( 'wppb_recover_password_password_changed_message1', '<p class="wppb-success">' . $message2 . '</p>', $message2 );
|
| 364 |
|
| 365 |
-
if( isset( $
|
| 366 |
-
echo '<p>' . $
|
| 367 |
}
|
| 368 |
}
|
| 369 |
|
| 343 |
}
|
| 344 |
}else{
|
| 345 |
if( $messageNo2 == '1' ) {
|
| 346 |
+
// CHECK FOR REDIRECT
|
| 347 |
+
$redirect_url = wppb_get_redirect_url( 'normal', 'after_success_password_reset', '', $_GET['loginName'] );
|
| 348 |
+
$redirect_delay = apply_filters( 'wppb_success_password_reset_redirect_delay', 3, $_GET['loginName'] );
|
| 349 |
+
$redirect_message = wppb_build_redirect( $redirect_url, $redirect_delay, 'after_success_password_reset' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 350 |
|
| 351 |
echo apply_filters( 'wppb_recover_password_password_changed_message1', '<p class="wppb-success">' . $message2 . '</p>', $message2 );
|
| 352 |
|
| 353 |
+
if( isset( $redirect_message ) && ! empty( $redirect_message ) ) {
|
| 354 |
+
echo '<p>' . $redirect_message . '</p>';
|
| 355 |
}
|
| 356 |
}
|
| 357 |
|
front-end/register.php
CHANGED
|
@@ -114,25 +114,14 @@ function wppb_activate_signup( $key ) {
|
|
| 114 |
|
| 115 |
do_action( 'wppb_activate_user', $user_id, $password, $meta );
|
| 116 |
|
| 117 |
-
if
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
if( isset( $wppb_module_settings['wppb_customRedirect'] ) && $wppb_module_settings['wppb_customRedirect'] == 'show' && function_exists( 'wppb_custom_redirect_url' ) ) {
|
| 123 |
-
$redirect_url = wppb_custom_redirect_url( 'after_success_email_confirmation', '', $user_login );
|
| 124 |
-
}
|
| 125 |
-
}
|
| 126 |
-
$redirect_url = apply_filters( 'wppb_success_email_confirmation_redirect_url', $redirect_url, $user_id );
|
| 127 |
-
$wppb_cr_delay = apply_filters( 'wppb_success_email_confirmation_redirect_delay', $wppb_cr_delay = 5, $user_id );
|
| 128 |
|
| 129 |
$success_message = apply_filters( 'wppb_success_email_confirmation', '<p class="wppb-success">' . __( 'Your email was successfully confirmed.', 'profile-builder' ) . '</p><!-- .success -->', $user_id );
|
| 130 |
-
$admin_approval_message = apply_filters( 'wppb_email_confirmation_with_admin_approval', '<p class="alert">' . __('Before you can access your account, an administrator needs to approve it. You will be notified via email.', 'profile-builder' ) . '</p>', $user_id );
|
| 131 |
-
|
| 132 |
-
if( ! empty( $redirect_url ) ) {
|
| 133 |
-
$wppb_cr_success_message = apply_filters( 'wppb_success_email_confirmation_redirect_message', '<p class="wppb-success">' . __( 'You will soon be redirected automatically.', 'profile-builder' ) . '</p>' );
|
| 134 |
-
$wppb_cr_success_message .= apply_filters( 'wppb_success_email_confirmation_redirect', '<meta http-equiv="Refresh" content="'.$wppb_cr_delay.';url='.$redirect_url.'" />', $wppb_cr_delay, $redirect_url, $user_id );
|
| 135 |
-
}
|
| 136 |
|
| 137 |
$wppb_general_settings = get_option( 'wppb_general_settings', 'false' );
|
| 138 |
|
|
@@ -142,22 +131,22 @@ function wppb_activate_signup( $key ) {
|
|
| 142 |
if( $wppb_general_settings != 'not_found' && ! empty( $wppb_general_settings['adminApprovalOnUserRole'] ) ) {
|
| 143 |
foreach( $user_data->roles as $role ) {
|
| 144 |
if( in_array( $role, $wppb_general_settings['adminApprovalOnUserRole'] ) ) {
|
| 145 |
-
return $success_message . $admin_approval_message. ( ! empty ( $
|
| 146 |
} else {
|
| 147 |
wp_set_object_terms( $user_id, NULL, 'user_status' );
|
| 148 |
clean_object_term_cache( $user_id, 'user_status' );
|
| 149 |
|
| 150 |
-
return $success_message. ( ! empty ( $
|
| 151 |
}
|
| 152 |
}
|
| 153 |
} else {
|
| 154 |
-
return $success_message . $admin_approval_message. ( ! empty ( $
|
| 155 |
}
|
| 156 |
} else {
|
| 157 |
wp_set_object_terms( $user_id, NULL, 'user_status' );
|
| 158 |
clean_object_term_cache( $user_id, 'user_status' );
|
| 159 |
|
| 160 |
-
return $success_message. ( ! empty ( $
|
| 161 |
}
|
| 162 |
} else {
|
| 163 |
return apply_filters('wppb_register_failed_user_activation', '<p class="error">'. __('There was an error while trying to activate the user.', 'profile-builder') .'</p><!-- .error -->');
|
|
@@ -167,11 +156,11 @@ function wppb_activate_signup( $key ) {
|
|
| 167 |
|
| 168 |
//function to display the registration page
|
| 169 |
function wppb_front_end_register( $atts ){
|
| 170 |
-
extract( shortcode_atts( array( 'role' => get_option( 'default_role' ), 'form_name' => 'unspecified', 'redirect_url' => '', 'redirect_priority' => 'normal' ), $atts, 'wppb-register' ) );
|
| 171 |
|
| 172 |
global ${$form_name};
|
| 173 |
|
| 174 |
-
$$form_name = new Profile_Builder_Form_Creator( array( 'form_type' => 'register', 'form_name' => $form_name, 'role' => ( is_object( get_role( $role ) ) ? $role : get_option( 'default_role' ) ) , 'redirect_url' => $redirect_url, 'redirect_priority' => $redirect_priority ) );
|
| 175 |
|
| 176 |
return $$form_name;
|
| 177 |
}
|
| 114 |
|
| 115 |
do_action( 'wppb_activate_user', $user_id, $password, $meta );
|
| 116 |
|
| 117 |
+
if( $inserted_user ) {
|
| 118 |
+
// CHECK FOR REDIRECT
|
| 119 |
+
$redirect_url = wppb_get_redirect_url( 'normal', 'after_success_email_confirmation', '', $user_login );
|
| 120 |
+
$redirect_delay = apply_filters( 'wppb_success_email_confirmation_redirect_delay', 3, $user_id );
|
| 121 |
+
$redirect_message = wppb_build_redirect( $redirect_url, $redirect_delay, 'after_success_email_confirmation' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
$success_message = apply_filters( 'wppb_success_email_confirmation', '<p class="wppb-success">' . __( 'Your email was successfully confirmed.', 'profile-builder' ) . '</p><!-- .success -->', $user_id );
|
| 124 |
+
$admin_approval_message = apply_filters( 'wppb_email_confirmation_with_admin_approval', '<p class="alert">' . __( 'Before you can access your account, an administrator needs to approve it. You will be notified via email.', 'profile-builder' ) . '</p>', $user_id );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
|
| 126 |
$wppb_general_settings = get_option( 'wppb_general_settings', 'false' );
|
| 127 |
|
| 131 |
if( $wppb_general_settings != 'not_found' && ! empty( $wppb_general_settings['adminApprovalOnUserRole'] ) ) {
|
| 132 |
foreach( $user_data->roles as $role ) {
|
| 133 |
if( in_array( $role, $wppb_general_settings['adminApprovalOnUserRole'] ) ) {
|
| 134 |
+
return $success_message . $admin_approval_message . ( ! empty ( $redirect_message ) ? $redirect_message : '' );
|
| 135 |
} else {
|
| 136 |
wp_set_object_terms( $user_id, NULL, 'user_status' );
|
| 137 |
clean_object_term_cache( $user_id, 'user_status' );
|
| 138 |
|
| 139 |
+
return $success_message . ( ! empty ( $redirect_message ) ? $redirect_message : '' );
|
| 140 |
}
|
| 141 |
}
|
| 142 |
} else {
|
| 143 |
+
return $success_message . $admin_approval_message . ( ! empty ( $redirect_message ) ? $redirect_message : '' );
|
| 144 |
}
|
| 145 |
} else {
|
| 146 |
wp_set_object_terms( $user_id, NULL, 'user_status' );
|
| 147 |
clean_object_term_cache( $user_id, 'user_status' );
|
| 148 |
|
| 149 |
+
return $success_message . ( ! empty ( $redirect_message ) ? $redirect_message : '' );
|
| 150 |
}
|
| 151 |
} else {
|
| 152 |
return apply_filters('wppb_register_failed_user_activation', '<p class="error">'. __('There was an error while trying to activate the user.', 'profile-builder') .'</p><!-- .error -->');
|
| 156 |
|
| 157 |
//function to display the registration page
|
| 158 |
function wppb_front_end_register( $atts ){
|
| 159 |
+
extract( shortcode_atts( array( 'role' => get_option( 'default_role' ), 'form_name' => 'unspecified', 'redirect_url' => '', 'logout_redirect_url' => '', 'redirect_priority' => 'normal' ), $atts, 'wppb-register' ) );
|
| 160 |
|
| 161 |
global ${$form_name};
|
| 162 |
|
| 163 |
+
$$form_name = new Profile_Builder_Form_Creator( array( 'form_type' => 'register', 'form_name' => $form_name, 'role' => ( is_object( get_role( $role ) ) ? $role : get_option( 'default_role' ) ) , 'redirect_url' => $redirect_url, 'logout_redirect_url' => $logout_redirect_url, 'redirect_priority' => $redirect_priority ) );
|
| 164 |
|
| 165 |
return $$form_name;
|
| 166 |
}
|
index.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
Plugin Name: Profile Builder
|
| 4 |
Plugin URI: https://www.cozmoslabs.com/wordpress-profile-builder/
|
| 5 |
Description: Login, registration and edit profile shortcodes for the front-end. Also you can chose what fields should be displayed or add new (custom) ones both in the front-end and in the dashboard.
|
| 6 |
-
Version: 2.5.
|
| 7 |
Author: Cozmoslabs, Madalin Ungureanu, Antohe Cristian, Barina Gabriel, Mihai Iova
|
| 8 |
Author URI: https://www.cozmoslabs.com/
|
| 9 |
License: GPL2
|
|
@@ -58,11 +58,11 @@ function wppb_free_plugin_init() {
|
|
| 58 |
switch (strtolower($val[strlen($val) - 1])) {
|
| 59 |
// The 'G' modifier is available since PHP 5.1.0
|
| 60 |
case 'g':
|
| 61 |
-
$val
|
| 62 |
case 'm':
|
| 63 |
-
$val
|
| 64 |
case 'k':
|
| 65 |
-
$val
|
| 66 |
}
|
| 67 |
|
| 68 |
return $val;
|
|
@@ -73,7 +73,7 @@ function wppb_free_plugin_init() {
|
|
| 73 |
*
|
| 74 |
*
|
| 75 |
*/
|
| 76 |
-
define('PROFILE_BUILDER_VERSION', '2.5.
|
| 77 |
define('WPPB_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
| 78 |
define('WPPB_PLUGIN_URL', plugin_dir_url(__FILE__));
|
| 79 |
define('WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE', apply_filters('wppb_server_max_upload_size_byte_constant', wppb_return_bytes(ini_get('upload_max_filesize'))));
|
| 3 |
Plugin Name: Profile Builder
|
| 4 |
Plugin URI: https://www.cozmoslabs.com/wordpress-profile-builder/
|
| 5 |
Description: Login, registration and edit profile shortcodes for the front-end. Also you can chose what fields should be displayed or add new (custom) ones both in the front-end and in the dashboard.
|
| 6 |
+
Version: 2.5.6
|
| 7 |
Author: Cozmoslabs, Madalin Ungureanu, Antohe Cristian, Barina Gabriel, Mihai Iova
|
| 8 |
Author URI: https://www.cozmoslabs.com/
|
| 9 |
License: GPL2
|
| 58 |
switch (strtolower($val[strlen($val) - 1])) {
|
| 59 |
// The 'G' modifier is available since PHP 5.1.0
|
| 60 |
case 'g':
|
| 61 |
+
$val = intval($val) * 1024;
|
| 62 |
case 'm':
|
| 63 |
+
$val = intval($val) * 1024;
|
| 64 |
case 'k':
|
| 65 |
+
$val = intval($val) * 1024;
|
| 66 |
}
|
| 67 |
|
| 68 |
return $val;
|
| 73 |
*
|
| 74 |
*
|
| 75 |
*/
|
| 76 |
+
define('PROFILE_BUILDER_VERSION', '2.5.6' );
|
| 77 |
define('WPPB_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
| 78 |
define('WPPB_PLUGIN_URL', plugin_dir_url(__FILE__));
|
| 79 |
define('WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE', apply_filters('wppb_server_max_upload_size_byte_constant', wppb_return_bytes(ini_get('upload_max_filesize'))));
|
readme.txt
CHANGED
|
@@ -4,8 +4,8 @@ Donate link: http://www.cozmoslabs.com/wordpress-profile-builder/
|
|
| 4 |
Tags: user registration, user profile, user registration form, user fields, extra user fields, edit profile, user custom fields, front-end login, front-end edit profile, front-end user registration, email confirmation, login form
|
| 5 |
|
| 6 |
Requires at least: 3.1
|
| 7 |
-
Tested up to: 4.7.
|
| 8 |
-
Stable tag: 2.5.
|
| 9 |
License: GPLv2 or later
|
| 10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 11 |
|
|
@@ -150,6 +150,10 @@ This plugin adds/removes user fields in the front-end. Both default and extra pr
|
|
| 150 |
10. Profile Builder Login Widget
|
| 151 |
|
| 152 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
= 2.5.5 =
|
| 154 |
* Added Blog Details field type
|
| 155 |
* Email From Name and Subject should now display proper special characters in all cases
|
| 4 |
Tags: user registration, user profile, user registration form, user fields, extra user fields, edit profile, user custom fields, front-end login, front-end edit profile, front-end user registration, email confirmation, login form
|
| 5 |
|
| 6 |
Requires at least: 3.1
|
| 7 |
+
Tested up to: 4.7.2
|
| 8 |
+
Stable tag: 2.5.6
|
| 9 |
License: GPLv2 or later
|
| 10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 11 |
|
| 150 |
10. Profile Builder Login Widget
|
| 151 |
|
| 152 |
== Changelog ==
|
| 153 |
+
= 2.5.6 =
|
| 154 |
+
* Compatibility fix with php 7.1
|
| 155 |
+
* Redirects code refactoring which should fix some minor issues with redirects as well
|
| 156 |
+
|
| 157 |
= 2.5.5 =
|
| 158 |
* Added Blog Details field type
|
| 159 |
* Email From Name and Subject should now display proper special characters in all cases
|
