PK:\B&& register.phpnuW+Aget_row( $wpdb->prepare( "SELECT * FROM " . $wpdb->signups . " WHERE activation_key = %s", $key ) ) : $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $wpdb->base_prefix . "signups WHERE activation_key = %s", $key ) ) ); if ( empty( $signup ) || $signup->active ) { //bad key or already active } else { //check for password in signup meta $meta = unserialize( $signup->meta ); if ( !empty($meta['user_pass']) ) $password = $meta['user_pass']; } } return apply_filters( 'wppb_generated_random_password', $password, $key ); } add_filter( 'random_password', 'wppb_signup_password_random_password_filter' ); /** * Activate a signup. * * * @param string $key The activation key provided to the user. * @return array An array containing information about the activated user and/or blog */ function wppb_activate_signup( $key ) { global $wpdb; $bloginfo = get_bloginfo( 'name' ); $wppb_general_settings = get_option( 'wppb_general_settings' ); $signup = ( is_multisite() ? $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE activation_key = %s", $key) ) : $wpdb->get_row( $wpdb->prepare( "SELECT * FROM ".$wpdb->base_prefix."signups WHERE activation_key = %s", $key ) ) ); $user_login = ( ( isset( $wppb_general_settings['loginWith'] ) && ( $wppb_general_settings['loginWith'] == 'email' ) ) ? trim( $signup->user_email ) : trim( $signup->user_login ) ); $user_email = esc_sql( $signup->user_email ); /* the password is in hashed form in the signup table so we will add it later */ $password = NULL; $user_id = username_exists( $user_login ); if ( empty( $signup ) ) return apply_filters( 'wppb_register_activate_user_error_message1', '

'.__( 'Invalid activation key!', 'profile-builder' ).'

'); if ( $signup->active ) if ( empty( $signup->domain ) ) return apply_filters( 'wppb_register_activate_user_error_message2', '

'.__( 'This username is now active!', 'profile-builder' ).'

', $user_id ); $meta = unserialize( $signup->meta ); if ( !$user_id ) $user_id = wppb_create_user( $user_login, $password, $user_email ); else $user_already_exists = true; if ( ! $user_id ) return apply_filters( 'wppb_register_activate_user_error_message4', '

'.__('Could not create user!', 'profile-builder').'

' ); elseif ( isset( $user_already_exists ) && ( $user_already_exists == true ) ) return apply_filters( 'wppb_register_activate_user_error_message5', '

'.__( 'This username is already activated!', 'profile-builder' ).'

' ); else{ $inserted_user = ( is_multisite() ? $wpdb->update( $wpdb->signups, array( 'active' => 1, 'activated' => current_time( 'mysql', true ) ), array( 'activation_key' => $key ) ) : $wpdb->update( $wpdb->base_prefix.'signups', array( 'active' => 1, 'activated' => current_time( 'mysql', true ) ), array( 'activation_key' => $key ) ) ); wppb_add_meta_to_user_on_activation( $user_id, '', $meta ); // if admin approval is activated, then block the user untill he gets approved $wppb_generalSettings = get_option('wppb_general_settings'); if( wppb_get_admin_approval_option_value() === 'yes' ){ $user_data = get_userdata( $user_id ); if( $wppb_generalSettings != 'not_found' && ! empty( $wppb_generalSettings['adminApprovalOnUserRole'] ) ) { foreach( $user_data->roles as $role ) { if( in_array( $role, $wppb_generalSettings['adminApprovalOnUserRole'] ) ) { wp_set_object_terms( $user_id, array( 'unapproved' ), 'user_status', false); clean_object_term_cache( $user_id, 'user_status' ); } else { add_filter( 'wppb_register_success_message', 'wppb_noAdminApproval_successMessage' ); } } } else { wp_set_object_terms( $user_id, array( 'unapproved' ), 'user_status', false); clean_object_term_cache( $user_id, 'user_status' ); } } if ( !isset( $wppb_generalSettings['adminApproval'] ) ) $wppb_generalSettings['adminApproval'] = 'no'; /* copy the hashed password from signup meta to wp user table */ if( !empty( $meta['user_pass'] ) ){ /* we might still have the base64 encoded password in signups and not the hash */ if( base64_encode(base64_decode($meta['user_pass'], true)) === $meta['user_pass'] ) $meta['user_pass'] = wp_hash_password( $meta['user_pass'] ); $wpdb->update( $wpdb->users, array('user_pass' => $meta['user_pass'] ), array('ID' => $user_id) ); wp_cache_delete( $user_id, 'users' ); } wppb_notify_user_registration_email($bloginfo, $user_login, $user_email, 'sending', $password, wppb_get_admin_approval_option_value() ); do_action( 'wppb_activate_user', $user_id, $password, $meta ); if( $inserted_user ) { // CHECK FOR REDIRECT $redirect_url = wppb_get_redirect_url( 'normal', 'after_success_email_confirmation', '', $user_login ); $redirect_delay = apply_filters( 'wppb_success_email_confirmation_redirect_delay', 3, $user_id ); $redirect_message = wppb_build_redirect( $redirect_url, $redirect_delay, 'after_success_email_confirmation' ); $success_message = apply_filters( 'wppb_success_email_confirmation', '

' . __( 'Your email was successfully confirmed.', 'profile-builder' ) . '

', $user_id ); $admin_approval_message = apply_filters( 'wppb_email_confirmation_with_admin_approval', '

' . __( 'Before you can access your account, an administrator needs to approve it. You will be notified via email.', 'profile-builder' ) . '

', $user_id ); $wppb_general_settings = get_option( 'wppb_general_settings', 'false' ); if ( wppb_get_admin_approval_option_value() === 'yes' ){ $user_data = get_userdata( $user_id ); if( $wppb_general_settings != 'not_found' && ! empty( $wppb_general_settings['adminApprovalOnUserRole'] ) ) { foreach( $user_data->roles as $role ) { if( in_array( $role, $wppb_general_settings['adminApprovalOnUserRole'] ) ) { return $success_message . $admin_approval_message . ( ! empty ( $redirect_message ) ? $redirect_message : '' ); } else { wp_set_object_terms( $user_id, NULL, 'user_status' ); clean_object_term_cache( $user_id, 'user_status' ); return $success_message . ( ! empty ( $redirect_message ) ? $redirect_message : '' ); } } } else { return $success_message . $admin_approval_message . ( ! empty ( $redirect_message ) ? $redirect_message : '' ); } } else { wp_set_object_terms( $user_id, NULL, 'user_status' ); clean_object_term_cache( $user_id, 'user_status' ); return $success_message . ( ! empty ( $redirect_message ) ? $redirect_message : '' ); } } else { return apply_filters('wppb_register_failed_user_activation', '

'. __('There was an error while trying to activate the user.', 'profile-builder') .'

'); } } } //function to display the registration page function wppb_front_end_register( $atts ){ extract( shortcode_atts( array( 'role' => get_option( 'default_role' ), 'form_name' => 'unspecified', 'redirect_url' => '', 'logout_redirect_url' => '', 'redirect_priority' => 'normal' ), $atts, 'wppb-register' ) ); $form = 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 ) ); return $form; } // function to choose whether to display the registration page or the validation message function wppb_front_end_register_handler( $atts ){ return ( isset( $_GET['activation_key'] ) ? wppb_activate_signup ( sanitize_text_field( $_GET['activation_key'] ) ) : wppb_front_end_register( $atts ) ); } add_action( 'user_register', 'wppbc_disable_admin_approval_for_user_role', 99, 1 ); function wppbc_disable_admin_approval_for_user_role( $user_id ) { if ( current_user_can( 'delete_users' ) ) { wp_set_object_terms( $user_id, NULL, 'user_status' ); clean_object_term_cache( $user_id, 'user_status' ); } } /* authors and contributors shouldn't be allowed to create pages with the register shortcode in them */ add_filter( 'the_content', 'wppb_maybe_remove_register_shortcode' ); function wppb_maybe_remove_register_shortcode( $content ){ if ( has_shortcode( $content, 'wppb-register' ) ){ $author_id = get_the_author_meta( 'ID' ); if( !empty( $author_id ) ){ if( !user_can( $author_id, 'edit_others_posts' ) ) { remove_shortcode('wppb-register'); } } } return $content; } /* custom redirect after registration on wp default register form */ function wppb_default_registration_redirect( $user_id ) { $user_data = get_userdata( $user_id ); // CHECK FOR REDIRECT $_POST['redirect_to'] = wppb_get_redirect_url( 'normal', 'after_registration', $_POST['redirect_to'], $user_data ); $_POST['redirect_to'] = apply_filters( 'wppb_after_registration_redirect_url', $_POST['redirect_to'] ); } add_action( 'register_new_user', 'wppb_default_registration_redirect' );PK:\" logout.phpnuW+A 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 ) ); if( ! empty( $redirect ) ) { $redirect_url = $redirect; } // CHECK FOR REDIRECT $redirect_url = wppb_get_redirect_url( $redirect_priority, 'after_logout', $redirect_url, $current_user ); $redirect_url = apply_filters( 'wppb_after_logout_redirect_url', $redirect_url ); $logout_link = '' . $link_text . ''; $meta_tags = apply_filters( 'wppb_front_end_logout_meta_tags', array( '{{meta_user_name}}', '{{meta_first_name}}', '{{meta_last_name}}', '{{meta_display_name}}' ) ); $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 ) ); $text = apply_filters( 'wppb_front_end_logout_text', str_replace( $meta_tags, $meta_tags_values, $text ), $current_user ); return '

' . $text . '' . $logout_link . '

'; }PK:\&X&X recover.phpnuW+Adata->ID, 'user_status' ) ){ $message = ''. __('ERROR', 'profile-builder') . ': ' . __('Your account has to be confirmed by an administrator before you can use the "Password Reset" feature.', 'profile-builder'); $message = apply_filters('wppb_recover_password_unapporved_user', $message); } } return $message; } /** * Function that retrieves the unique user key from the database. If we don't have one we generate one and add it to the database * * @param string $requested_user_login the user login * */ function wppb_retrieve_activation_key( $requested_user_login ){ global $wpdb; $key = $wpdb->get_var( $wpdb->prepare( "SELECT user_activation_key FROM $wpdb->users WHERE user_login = %s", $requested_user_login ) ); if ( empty( $key ) ) { // Generate something random for a key... $key = wp_generate_password( 20, false ); do_action('wppb_retrieve_password_key', $requested_user_login, $key); // Now insert the new md5 key into the db $wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $requested_user_login)); } return $key; } /** * Function that creates a generate new password form * * @param array $post_data $_POST * */ function wppb_create_recover_password_form( $user, $post_data ){ ?>

" value="" />

ID, 'password_recovery_nonce_field2' ); ?>
' . __( 'Please enter your email address.', 'profile-builder' ); $username_email_label = __( 'E-mail', 'profile-builder' ); } else{ $recover_notification = '

' . __( 'Please enter your username or email address.', 'profile-builder' ); $username_email_label = __( 'Username or E-mail', 'profile-builder' ); } $recover_notification .= '
'.__( 'You will receive a link to create a new password via email.', 'profile-builder' ).'

'; echo apply_filters( 'wppb_recover_password_message1', $recover_notification ); $username_email = ( isset( $post_data['username_email'] ) ? $post_data['username_email'] : '' ); $recover_input = ''; echo apply_filters( 'wppb_recover_password_generate_password_input', $recover_input, trim( $username_email ) ); ?>

" value="" />

user_login; else $display_username_email = $user->user_email; return $display_username_email; } /** * Send the email for the password recovery request * @param $user * @return bool|string|void */ function wppb_send_recovery_email( $user ){ $requested_user_id = $user->ID; $requested_user_login = $user->user_login; $requested_user_email = $user->user_email; //search if there is already an activation key present, if not create one $key = wppb_retrieve_activation_key( $requested_user_login ); $display_username_email = wppb_get_email_display_username($user); //send primary email message $recovery_email_message = sprintf( __('Someone requested that the password be reset for the following account: %1$s
If this was a mistake, just ignore this email and nothing will happen.
To reset your password, visit the following link:%2$s', 'profile-builder'), $display_username_email, ''.esc_url( add_query_arg( array( 'key' => $key ), wppb_curpageurl() ) ).'' ); $recovery_email_message = apply_filters( 'wppb_recover_password_message_content_sent_to_user1', $recovery_email_message, $requested_user_id, $requested_user_login, $requested_user_email ); $recovery_email_message_title = sprintf(__('Password Reset from "%1$s"', 'profile-builder'), $blogname = get_option('blogname') ); $recovery_email_message_title = apply_filters('wppb_recover_password_message_title_sent_to_user1', $recovery_email_message_title, $requested_user_login); $recovery_email_from = apply_filters ( 'wppb_recover_password_notification_email_from_field', get_bloginfo( 'name' ) ); $recovery_email_context = 'email_user_recover'; $sent = false; //send mail to the user notifying him of the reset request if (trim($recovery_email_message_title) != '') { $sent = wppb_mail($requested_user_email, $recovery_email_message_title, $recovery_email_message, $recovery_email_from, $recovery_email_context); } return $sent; } /** * Function that sends the successful password reset email to the user * @param $user * @param $new_pass */ function wppb_send_successful_password_reset_email( $user, $new_pass ){ $display_username_email = wppb_get_email_display_username($user); //send secondary mail to the user containing the username and the new password $recovery_email_message = __( 'You have successfully reset your password.', 'profile-builder' ); $recovery_email_message = apply_filters( 'wppb_recover_password_message_content_sent_to_user2', $recovery_email_message, $display_username_email, $new_pass, $user->ID ); $recovery_email_message_title = sprintf( __('Password Successfully Reset for %1$s on "%2$s"', 'profile-builder' ), $display_username_email, $blogname = get_option('blogname') ); $recovery_email_message_title = apply_filters( 'wppb_recover_password_message_title_sent_to_user2', $recovery_email_message_title, $display_username_email ); $recovery_email_from = apply_filters ( 'wppb_recover_password_success_notification_email_from_field', get_bloginfo( 'name' ) ); $recovery_email_context = 'email_user_recover_success'; //send mail to the user notifying him of the reset request if ( trim( $recovery_email_message_title ) != '' ) wppb_mail( $user->user_email, $recovery_email_message_title, $recovery_email_message, $recovery_email_from, $recovery_email_context ); } /** * Function that sends an email to the admin after the password was reset * we disable the feature to send the admin a notification mail but can be still used using filters * @param $user */ function wppb_send_admin_password_reset_email( $user ){ $display_username_email = wppb_get_email_display_username($user); $recovery_admin_email_message = sprintf( __( '%1$s has requested a password change via the password reset feature.
His/her new password is:%2$s', 'profile-builder' ), $display_username_email, '' ); $recovery_admin_email_message = apply_filters( 'wppb_recover_password_message_content_sent_to_admin', $recovery_admin_email_message, $display_username_email, '', $user->ID ); //we disable the feature to send the admin a notification mail but can be still used using filters $recovery_admin_email_title = ''; $recovery_admin_email_title = apply_filters( 'wppb_recover_password_message_title_sent_to_admin', $recovery_admin_email_title, $display_username_email ); $recovery_email_from = apply_filters ( 'wppb_recover_password_success_notification_email_from_field', get_bloginfo( 'name' ) ); $recovery_admin_email_context = 'email_admin_recover_success'; //send mail to the admin notifying him of of a user with a password reset request if (trim($recovery_admin_email_title) != '') wppb_mail(get_option('admin_email'), $recovery_admin_email_title, $recovery_admin_email_message, $recovery_email_from, $recovery_admin_email_context); } /** * The function for the recover password shortcode * */ function wppb_front_end_password_recovery(){ global $wppb_shortcode_on_front; $wppb_shortcode_on_front = true; $password_email_sent = false; $password_changed_success = false; $output = '
'; global $wpdb; if( is_user_logged_in() ) return apply_filters( 'wppb_recover_password_already_logged_in', __( 'You are already logged in. You can change your password on the edit profile form.', 'profile-builder' ) ); //Get general settings $wppb_generalSettings = get_option( 'wppb_general_settings' ); // If the user entered an email/username, process the request if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'recover_password' && wp_verify_nonce($_POST['password_recovery_nonce_field'],'verify_true_password_recovery') ) { // filter must be applied on the $_POST variable so that the value returned to the form can be corrected too $username_email = apply_filters( 'wppb_before_processing_email_from_forms', $_POST['username_email'] ); //we get the raw data //check to see if it's an e-mail (and if this is valid/present in the database) or is a username // if we do not have an email in the posted date we try to get the email for that user if( !is_email( $username_email ) ){ /* make sure it is a username */ $username = sanitize_user( $username_email ); if ( username_exists($username) ){ $query = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE user_login= %s", $username ) ); if( !empty( $query[0] ) ){ $username_email = $query[0]->user_email; } } else{ $warning = __( 'The username entered wasn\'t found in the database!', 'profile-builder').'
'.__('Please check that you entered the correct username.', 'profile-builder' ); $warning = apply_filters( 'wppb_recover_password_sent_message4', $warning ); $output .= wppb_password_recovery_warning( $warning, 'wppb_recover_password_displayed_message1' ); } } // we should have an email by this point if ( is_email( $username_email ) ){ if ( email_exists( $username_email ) ){ $warning = wppb_check_for_unapproved_user($username_email, 'user_email'); if ($warning != ''){ $output .= wppb_password_recovery_warning( $warning, 'wppb_recover_password_displayed_message1' ); }else{ $success = sprintf( __( 'Check your e-mail for the confirmation link.', 'profile-builder'), $username_email ); $success = apply_filters( 'wppb_recover_password_sent_message1', $success, $username_email ); $output .= wppb_password_recovery_success( $success, 'wppb_recover_password_displayed_message2' ); //verify e-mail validity $query = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE user_email= %s", sanitize_email( $username_email ) ) ); if( !empty( $query[0] ) ){ $user = $query[0]; //send mail to the user notifying him of the reset request $sent = wppb_send_recovery_email( $user ); if ($sent === false){ $warning = ''. __( 'ERROR', 'profile-builder' ) .': ' . sprintf( __( 'There was an error while trying to send the activation link to %1$s!', 'profile-builder' ), $username_email ); $warning = apply_filters( 'wppb_recover_password_sent_message_error_sending', $warning ); wppb_password_recovery_warning( $warning, 'wppb_recover_password_displayed_message1' ); } else $password_email_sent = true; } } }elseif ( !email_exists( $username_email ) ){ $warning = __('The email address entered wasn\'t found in the database!', 'profile-builder').'
'.__('Please check that you entered the correct email address.', 'profile-builder'); $warning = apply_filters('wppb_recover_password_sent_message2', $warning); $output .= wppb_password_recovery_warning( $warning, 'wppb_recover_password_displayed_message1' ); } } } // If the user used the correct key-code, update his/her password elseif ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action2'] ) && $_POST['action2'] == 'recover_password2' && wp_verify_nonce( $_POST['password_recovery_nonce_field2'], 'verify_true_password_recovery2_'.absint( $_POST['userData'] ) ) ) { $password_change_message = ''; if( ( !empty( $_POST['passw1'] ) && !empty( $_POST['passw2'] ) ) ){ if( $_POST['passw1'] != $_POST['passw2'] ) { $password_change_message = __('The entered passwords don\'t match!', 'profile-builder'); $output .= wppb_password_recovery_error( $password_change_message, 'wppb_recover_password_password_changed_message2' ); } if( !empty( $wppb_generalSettings['minimum_password_length'] ) || ( isset( $_POST['wppb_password_strength'] ) && !empty( $wppb_generalSettings['minimum_password_strength'] ) ) ){ if( wppb_check_password_length( $_POST['passw1'] ) ){ $password_change_message = sprintf( __( "The password must have the minimum length of %s characters", "profile-builder" ), $wppb_generalSettings['minimum_password_length'] ) . '
'; $output .= wppb_password_recovery_error( $password_change_message, 'wppb_recover_password_password_changed_message2' ); } if( wppb_check_password_strength() ){ $password_change_message = sprintf( __( "The password must have a minimum strength of %s", "profile-builder" ), wppb_check_password_strength() ); $output .= wppb_password_recovery_error( $password_change_message, 'wppb_recover_password_password_changed_message2' ); } } if( empty($password_change_message) ){ $password_change_message = __( 'Your password has been successfully changed!', 'profile-builder' ); $output .= wppb_password_recovery_success( $password_change_message, 'wppb_recover_password_password_changed_message1' ); $password_changed_success = true; $userID = absint( $_POST['userData'] ); $new_pass = $_POST['passw1']; //update the new password and delete the key do_action( 'wppb_password_reset', $userID, $new_pass ); wp_set_password( $new_pass, $userID ); /* log out of all sessions on password reset */ $sessions = WP_Session_Tokens::get_instance( $userID ); $sessions->destroy_all(); $user_info = get_userdata( $userID ); //send email to user wppb_send_successful_password_reset_email( $user_info, $new_pass ); //send email to admin wppb_send_admin_password_reset_email( $user_info ); // CHECK FOR REDIRECT $redirect_url = wppb_get_redirect_url( 'normal', 'after_success_password_reset', '', sanitize_user( $user_info->user_login ) ); $redirect_delay = apply_filters( 'wppb_success_password_reset_redirect_delay', 3, sanitize_user( $user_info->user_login ) ); $redirect_message = wppb_build_redirect( $redirect_url, $redirect_delay, 'after_success_password_reset' ); if( isset( $redirect_message ) && ! empty( $redirect_message ) ) { $output .= '

' . $redirect_message . '

'; } } } else{ $password_change_message .= __( "The password must not be empty!", "profile-builder" ); $output .= wppb_password_recovery_error( $password_change_message, 'wppb_recover_password_password_changed_message2' ); } } // use this action hook to add extra content before the password recovery form do_action( 'wppb_before_recover_password_fields' ); //this is the part that shows the forms if( isset( $_GET['key'] ) && !empty( $_GET['key'] ) ){ if( !$password_changed_success ) { //get the login name and key and verify if they match the ones in the database $key = sanitize_text_field( $_GET['key'] ); $user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE user_activation_key = %s", $key ) ); if( !empty( $user ) ) { ob_start(); wppb_create_recover_password_form($user, $_POST); $output .= ob_get_contents(); ob_end_clean(); } else { $output .= wppb_password_recovery_error('' . __('ERROR:', 'profile-builder') . '' . __('Invalid key!', 'profile-builder'), 'wppb_recover_password_invalid_key_message'); } } } else{ if( !$password_email_sent ) { ob_start(); wppb_create_generate_password_form($_POST); $output .= ob_get_contents(); ob_end_clean(); } } // use this action hook to add extra content after the password recovery form. do_action( 'wppb_after_recover_password_fields' ); $output .= '
'; return $output; } /* function for displaying success messages on the recover password page */ function wppb_password_recovery_success( $message, $filter ){ return apply_filters( $filter, '

'.$message.'

', $message ); } /* function for displaying warning messages on the recover password page */ function wppb_password_recovery_warning( $message, $filter ){ return apply_filters( $filter, '

'.$message.'

', $message ); } /* function for displaying error messages on the recover password page */ function wppb_password_recovery_error( $message, $filter ){ return apply_filters( $filter, '

'.$message.'

', $message ); } PK:\tWppclass-formbuilder.phpnuW+A '', 'form_fields' => array(), 'form_name' => '', 'role' => '', //used only for the register-form settings 'redirect_url' => '', 'logout_redirect_url' => '', //used only for the register-form settings 'redirect_priority' => 'normal', 'ID' => null ); public $args; // Constructor method for the class function __construct( $args ) { /* we should stop the execution of the forms if they are in the wp_head hook because it should not be there. SEO plugins can execute shortcodes in the auto generated descriptions */ if( apply_filters( 'wppb_dont_render_form_in_wp_head_hook', true ) ){ global $wp_current_filter; if( !empty( $wp_current_filter ) && is_array( $wp_current_filter ) ){ foreach( $wp_current_filter as $filter ){ if( $filter == 'wp_head' ) return; } } } // Merge the input arguments and the defaults $this->args = wp_parse_args( $args, $this->defaults ); /* set up the ID here if it is a multi form */ if( $this->args['form_name'] != 'unspecified' ){ $this->args['ID'] = Profile_Builder_Form_Creator::wppb_get_form_id_from_form_name( $this->args['form_name'], $this->args['form_type'] ); } global $wppb_shortcode_on_front; $wppb_shortcode_on_front = true; if( empty( $this->args['form_fields'] ) ) $this->args['form_fields'] = apply_filters( 'wppb_change_form_fields', get_option( 'wppb_manage_fields' ), $this->args ); if ( file_exists ( WPPB_PLUGIN_DIR.'/front-end/default-fields/default-fields.php' ) ) require_once( WPPB_PLUGIN_DIR.'/front-end/default-fields/default-fields.php' ); if ( file_exists ( WPPB_PLUGIN_DIR.'/front-end/extra-fields/extra-fields.php' ) ) require_once( WPPB_PLUGIN_DIR.'/front-end/extra-fields/extra-fields.php' ); $this->wppb_retrieve_custom_settings(); if( ( !is_multisite() && current_user_can( 'edit_users' ) ) || ( is_multisite() && current_user_can( 'manage_network' ) ) ) add_action( 'wppb_before_edit_profile_fields', array( 'Profile_Builder_Form_Creator', 'wppb_edit_profile_select_user_to_edit' ) ); //enqueue frontend scripts for forms add_action( 'wp_footer', array( $this, 'wppb_frontend_scripts' ), 9999 ); } /** * @param $form_name The "slug" generated from the current Form Title * @param $form_type the form type of the form: register, edit_profile * @return null */ static function wppb_get_form_id_from_form_name( $form_name, $form_type ){ global $wpdb; if( $form_type == 'edit_profile' ){ $post_type = 'wppb-epf-cpt'; }elseif( $form_type == 'register' ){ $post_type = 'wppb-rf-cpt'; } $all_forms = $wpdb->get_results( " SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = '$post_type' " ); if( !empty( $all_forms ) ) { foreach ($all_forms as $form) { if( empty( $form->post_title ) ) $form->post_title = '(no title)'; if ($form_name == Wordpress_Creation_Kit_PB::wck_generate_slug($form->post_title)) { return $form->ID; } } } return null; } function wppb_retrieve_custom_settings(){ $this->args['login_after_register'] = apply_filters( 'wppb_automatically_login_after_register', 'No' ); //used only for the register-form settings $this->args['redirect_activated'] = apply_filters( 'wppb_redirect_default_setting', '-' ); $this->args['redirect_url'] = apply_filters( 'wppb_redirect_default_location', ( $this->args['redirect_url'] != '' ) ? $this->args['redirect_url'] : '' ); $this->args['logout_redirect_url'] = apply_filters( 'wppb_logout_redirect_default_location', ( $this->args['logout_redirect_url'] != '' ) ? $this->args['logout_redirect_url'] : '' ); $this->args['redirect_delay'] = apply_filters( 'wppb_redirect_default_duration', 3 ); if ( !is_null( $this->args['ID'] ) ){ $meta_name = ( ( $this->args['form_type'] == 'register' ) ? 'wppb_rf_page_settings' : 'wppb_epf_page_settings' ); $page_settings = get_post_meta( $this->args['ID'], $meta_name, true ); if( !empty( $page_settings[0]['set-role'] ) ){ if( $page_settings[0]['set-role'] == 'default role' ){ $selected_role = trim( get_option( 'default_role' ) ); } else $selected_role = $page_settings[0]['set-role']; } $this->args['role'] = ( isset( $selected_role ) ? $selected_role : $this->args['role'] ); $this->args['login_after_register'] = ( isset( $page_settings[0]['automatically-log-in'] ) ? $page_settings[0]['automatically-log-in'] : $this->args['login_after_register'] ); $this->args['redirect_activated'] = ( isset( $page_settings[0]['redirect'] ) ? $page_settings[0]['redirect'] : $this->args['redirect_activated'] ); $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'] ); $this->args['redirect_delay'] = ( isset( $page_settings[0]['display-messages'] ) && $this->args['redirect_activated'] == 'Yes' ? $page_settings[0]['display-messages'] : $this->args['redirect_delay'] ); } if( !empty( $this->args['role'] ) ){ $role_in_arg = get_role( $this->args['role'] ); if( !empty( $role_in_arg->capabilities['manage_options'] ) || !empty( $role_in_arg->capabilities['remove_users'] ) ){ if( !current_user_can( 'manage_options' ) || !current_user_can( 'remove_users' ) ){ $this->args['role'] = get_option('default_role'); echo apply_filters( 'wppb_register_pre_form_user_role_message', '

'.__( 'The role of the created user set to the default role. Only an administrator can register a user with the role assigned to this form.', 'profile-builder').'

' ); } } } } function wppb_form_logic() { if( $this->args['form_type'] == 'register' ){ $registration = apply_filters ( 'wppb_register_setting_override', true );//used to be get_option( 'users_can_register' ) if ( !is_user_logged_in() ){ if ( !$registration ) echo apply_filters( 'wppb_register_pre_form_message', '

'.esc_html(__( 'Only an administrator can add new users.', 'profile-builder')).'

' ); elseif ( $registration ){ $this->wppb_form_content( apply_filters( 'wppb_register_pre_form_message', '' ) ); } }else{ $current_user_capability = apply_filters ( 'wppb_registration_user_capability', 'create_users' ); if ( current_user_can( $current_user_capability ) && $registration ) $this->wppb_form_content( apply_filters( 'wppb_register_pre_form_message', '

'.esc_html(__( 'Users can register themselves or you can manually create users here.', 'profile-builder')). '' . '

' ) ); elseif ( current_user_can( $current_user_capability ) && !$registration ) $this->wppb_form_content( apply_filters( 'wppb_register_pre_form_message', '

'.esc_html(__( 'Users cannot currently register themselves, but you can manually create users here.', 'profile-builder')). '' . '

' ) ); elseif ( !current_user_can( $current_user_capability ) ){ global $user_ID; $userdata = get_userdata( $user_ID ); $display_name = ( ( $userdata->data->display_name == '' ) ? $userdata->data->user_login : $userdata->data->display_name ); $wppb_general_settings = get_option( 'wppb_general_settings' ); if ( isset( $wppb_general_settings['loginWith'] ) && ( $wppb_general_settings['loginWith'] == 'email' ) ) $display_name = $userdata->data->user_email; if( empty( $this->args['logout_redirect_url'] ) ) { $this->args['logout_redirect_url'] = get_permalink(); } // CHECK FOR REDIRECT $this->args['logout_redirect_url'] = wppb_get_redirect_url( $this->args['redirect_priority'], 'after_logout', $this->args['logout_redirect_url'], $userdata ); $this->args['logout_redirect_url'] = apply_filters( 'wppb_after_logout_redirect_url', $this->args['logout_redirect_url'] ); echo apply_filters( 'wppb_register_pre_form_message', '

'.sprintf( __( "You are currently logged in as %1s. You don't need another account. %2s", 'profile-builder' ), ''.$display_name.'', ''.__( 'Logout', 'profile-builder' ).' »' ).'

', $user_ID ); } } }elseif ( $this->args['form_type'] == 'edit_profile' ){ if ( !is_user_logged_in() ) echo apply_filters( 'wppb_edit_profile_user_not_logged_in_message', '

'.esc_html(__( 'You must be logged in to edit your profile.', 'profile-builder' )) .'

' ); elseif ( is_user_logged_in() ) $this->wppb_form_content( apply_filters( 'wppb_edit_profile_logged_in_user_message', '' ) ); } } // Function used to automatically log in a user after register if that option is set on yes in register form settings function wppb_log_in_user( $redirect, $redirect_old ) { if( is_user_logged_in() ) { return; } $wppb_general_settings = get_option( 'wppb_general_settings' ); if ( isset( $wppb_general_settings['emailConfirmation'] ) && ( $wppb_general_settings['emailConfirmation'] == 'yes' ) ) { return $redirect_old; } /* get user id */ $user = get_user_by( 'email', trim( sanitize_email( $_POST['email'] ) ) ); $nonce = wp_create_nonce( 'autologin-'. $user->ID .'-'. (int)( time() / 60 ) ); if ( wppb_get_admin_approval_option_value() === 'yes' ) { if( !empty( $wppb_general_settings['adminApprovalOnUserRole'] ) ) { foreach ($user->roles as $role) { if ( in_array( $role, $wppb_general_settings['adminApprovalOnUserRole'] ) ) { return $redirect_old; } } } else { return $redirect_old; } } /* define redirect location */ if( $this->args['redirect_activated'] == 'No' ) { if( isset( $_POST['_wp_http_referer'] ) ) { $redirect = esc_url_raw($_POST['_wp_http_referer']); } else { $redirect = home_url(); } } if( empty( $redirect ) ) $redirect = wppb_curpageurl(); $redirect = apply_filters( 'wppb_login_after_reg_redirect_url', $redirect, $this ); $redirect = add_query_arg( array( 'autologin' => 'true', 'uid' => $user->ID, '_wpnonce' => $nonce ), $redirect ); // CHECK FOR REDIRECT if( $this->args['redirect_activated'] == 'No' || ( empty( $this->args['redirect_delay'] ) || $this->args['redirect_delay'] == '0' ) ) { $redirect = wppb_build_redirect( $redirect, 0, 'register', $this->args ); } else { $redirect = wppb_build_redirect( $redirect, $this->args['redirect_delay'], 'register', $this->args ); } return $redirect; } /** * Function to get redirect for Register and Edit Profile forms * * @param string $form_type - type of the form * @param string $redirect_type - type of the redirect * @param string $user - username or user email * @param string $user_role - user Role * * @return string $redirect */ function wppb_get_redirect( $form_type, $redirect_type, $user, $user_role ) { $this->args['redirect_delay'] = apply_filters( 'wppb_'. $form_type .'_redirect_delay', $this->args['redirect_delay'], $user, $this->args ); if( $this->args['redirect_activated'] == '-' ) { $this->args['redirect_url'] = wppb_get_redirect_url( $this->args['redirect_priority'], $redirect_type, $this->args['redirect_url'], $user, $user_role ); $redirect = wppb_build_redirect( $this->args['redirect_url'], $this->args['redirect_delay'], $form_type, $this->args ); } elseif( $this->args['redirect_activated'] == 'Yes' ) { $redirect = wppb_build_redirect( $this->args['redirect_url'], $this->args['redirect_delay'], $form_type, $this->args ); } else { $redirect = ''; } return $redirect; } function wppb_form_content( $message ) { $field_check_errors = array(); ob_start(); if( isset( $_REQUEST['action'] ) && $_REQUEST['form_name'] == $this->args['form_name'] ) { if( ! isset( $_POST[$this->args['form_type'].'_'. $this->args['form_name'] .'_nonce_field'] ) || ! wp_verify_nonce( $_POST[$this->args['form_type'].'_'. $this->args['form_name'] .'_nonce_field'], 'wppb_verify_form_submission' ) ) { echo ''. esc_html(__( 'You are not allowed to do this.', 'profile-builder' )) . ''; return; } $field_check_errors = $this->wppb_test_required_form_values( $_REQUEST ); if( empty( $field_check_errors ) ) { do_action( 'wppb_before_saving_form_values',$_REQUEST, $this->args ); // we only have a $user_id on default registration (no email confirmation, no multisite) $user_id = $this->wppb_save_form_values( $_REQUEST ); if( ( 'POST' == $_SERVER['REQUEST_METHOD'] ) && ( $_POST['action'] == $this->args['form_type'] ) ) { $form_message_tpl_start = apply_filters( 'wppb_form_message_tpl_start', '

' ); $form_message_tpl_end = apply_filters( 'wppb_form_message_tpl_end', '

' ); if( ! current_user_can( 'manage_options' ) && $this->args['form_type'] != 'edit_profile' && isset( $_POST['custom_field_user_role'] ) ) { $user_role = sanitize_text_field($_POST['custom_field_user_role']); } elseif( ! current_user_can( 'manage_options' ) && $this->args['form_type'] != 'edit_profile' && isset( $this->args['role'] ) ) { $user_role = $this->args['role']; } else { $user_role = NULL; } if( isset( $_POST['username'] ) && ( trim( $_POST['username'] ) != '' ) ) { $account_name = sanitize_user( $_POST['username'] ); } elseif( isset( $_POST['email'] ) && ( trim( $_POST['email'] ) != '' ) ) { $account_name = sanitize_email( $_POST['email'] ); }else{ /* we are in the edit form with no username or email field */ $current_user = wp_get_current_user(); if( !empty( $current_user ) ) $account_name = $current_user->user_login; } if( $this->args['form_type'] == 'register' ) { // ec = email confirmation setting // aa = admin approval setting $wppb_general_settings = get_option( 'wppb_general_settings', 'false' ); if ( $wppb_general_settings ) { if( !empty( $wppb_general_settings['emailConfirmation'] ) && apply_filters( 'wppb_email_confirmation_on_register', $wppb_general_settings['emailConfirmation'], $_POST ) == 'yes' ) $wppb_email_confirmation = $wppb_general_settings['emailConfirmation']; else $wppb_email_confirmation = 'no'; $wppb_admin_approval = wppb_get_admin_approval_option_value(); $account_management_settings = 'ec-' . $wppb_email_confirmation . '_' . 'aa-' . $wppb_admin_approval; } else { $account_management_settings = 'ec-no_aa-no'; } switch( $account_management_settings ) { case 'ec-no_aa-no': $wppb_register_success_message = apply_filters( 'wppb_register_success_message', sprintf( __( "The account %1s has been successfully created!", 'profile-builder' ), $account_name ), $account_name ); break; case 'ec-yes_aa-no': $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 ); break; case 'ec-no_aa-yes': if( current_user_can( 'delete_users' ) ) { $wppb_register_success_message = apply_filters( 'wppb_register_success_message', sprintf( __( "The account %1s has been successfully created!", 'profile-builder' ), $account_name ), $account_name ); } else { $wppb_register_success_message = apply_filters( 'wppb_register_success_message', sprintf( __( "Before you can access your account %1s, an administrator has to approve it. You will be notified via email.", 'profile-builder' ), $account_name ), $account_name ); } break; case 'ec-yes_aa-yes': $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 ); break; } // CHECK FOR REDIRECT $redirect = $this->wppb_get_redirect( 'register', 'after_registration', $account_name, $user_role ); if( $this->args['login_after_register'] == 'Yes' ) { $redirect = $this->wppb_log_in_user( $this->args['redirect_url'], $redirect ); } echo $form_message_tpl_start . $wppb_register_success_message . $form_message_tpl_end . $redirect; //action hook after registration success do_action( 'wppb_register_success', $_REQUEST, $this->args['form_name'], $user_id ); return; } elseif( $this->args['form_type'] == 'edit_profile' ) { // CHECK FOR REDIRECT $redirect = $this->wppb_get_redirect( 'edit_profile', 'after_edit_profile', $account_name, $user_role ); echo $form_message_tpl_start . apply_filters( 'wppb_edit_profile_success_message', esc_html(__( 'Your profile has been successfully updated!', 'profile-builder' )) ) . $form_message_tpl_end . $redirect; //action hook after edit profile success do_action( 'wppb_edit_profile_success', $_REQUEST, $this->args['form_name'], $user_id ); if( apply_filters( 'wppb_no_form_after_profile_update', false ) ) return; } } }else echo $message.apply_filters( 'wppb_general_top_error_message', '

'.esc_html(__( 'There was an error in the submitted form', 'profile-builder' )).'

' ); }else echo $message; // use this action hook to add extra content before the register form do_action( 'wppb_before_'.$this->args['form_type'].'_fields', $this->args['form_name'], $this->args['ID'], $this->args['form_type'] ); $wppb_user_role_class = ''; if( is_user_logged_in() ) { $wppb_user = wp_get_current_user(); if( $wppb_user && isset( $wppb_user->roles ) ) { foreach( $wppb_user->roles as $wppb_user_role ) { $wppb_user_role_class .= ' wppb-user-role-'. $wppb_user_role; } } } else { $wppb_user_role_class = ' wppb-user-logged-out'; } $wppb_user_role_class = apply_filters( 'wppb_user_role_form_class', $wppb_user_role_class ); /* set up form id */ $wppb_form_id = ''; if( $this->args['form_type'] == 'register' ) $wppb_form_id = 'wppb-register-user'; elseif( $this->args['form_type'] == 'edit_profile' ) $wppb_form_id = 'wppb-edit-user'; if( isset($this->args['form_name']) && $this->args['form_name'] != "unspecified" ) $wppb_form_id .= '-' . $this->args['form_name']; /* set up form class */ $wppb_form_class = 'wppb-user-forms'; if( $this->args['form_type'] == 'register' ) $wppb_form_class .= ' wppb-register-user'; elseif( $this->args['form_type'] == 'edit_profile' ) $wppb_form_class .= ' wppb-edit-user'; $wppb_form_class .= $wppb_user_role_class; ?>
args ); echo apply_filters( 'wppb_before_form_fields', '', $this->args['form_type'], $this->args['ID'] ); echo apply_filters( 'wppb_before_send_credentials_checkbox', '', $this->args['form_type'] ); $wppb_form_submit_extra_attr = apply_filters( 'wppb_form_submit_extra_attr', '', $this->args['form_type'], $this->args['ID'] ); ?>

> args['form_type'] == 'register' ) $button_name = ( current_user_can( 'create_users' ) ? __( 'Add User', 'profile-builder' ) : __( 'Register', 'profile-builder' ) ); elseif( $this->args['form_type'] == 'edit_profile' ) $button_name = __( 'Update', 'profile-builder' ); ?> args ); ?> " value="args['form_type'] .'_button_name', esc_attr( $button_name ), $this->args['form_name'] ); ?>" args['form_type'] );?>/> args ); ?> '; } ?>

args['form_type'].'_'. $this->args['form_name'] .'_nonce_field' ); ?>
args['form_type'] .'_fields', $this->args['form_name'], $this->args['ID'], $this->args['form_type'] ); $form_content = ob_get_clean(); echo apply_filters( 'wppb_' . $this->args['form_type'] . '_form_content', $form_content ); } function wppb_output_form_fields( $global_request, $field_check_errors, $form_fields, $called_from = NULL ){ $wppb_generalSettings = get_option( 'wppb_general_settings' ); $output_fields = ''; if( !empty( $form_fields ) ){ $output_fields .= apply_filters( 'wppb_output_before_first_form_field', '', $this->args['ID'], $this->args['form_type'], $form_fields, $called_from ); foreach( $form_fields as $field ){ $error_var = ( ( array_key_exists( $field['id'], $field_check_errors ) ) ? ' wppb-field-error' : '' ); $specific_message = ( ( array_key_exists( $field['id'], $field_check_errors ) ) ? $field_check_errors[$field['id']] : '' ); $display_field = apply_filters( 'wppb_output_display_form_field', true, $field, $this->args['form_type'], $this->args['role'], $this->wppb_get_desired_user_id() ); if( $display_field == false ) continue; $css_class = apply_filters( 'wppb_field_css_class', 'wppb-form-field wppb-'. Wordpress_Creation_Kit_PB::wck_generate_slug( $field['field'] ) .$error_var, $field, $error_var ); $output_fields .= apply_filters( 'wppb_output_before_form_field', '
  • ', $field, $error_var, $this->args['role'] ); $render_field = true; if( wppb_conditional_fields_exists() && isset( $wppb_generalSettings['conditional_fields_ajax'] ) ){ if($wppb_generalSettings['conditional_fields_ajax'] === 'yes' && isset($field['conditional-logic-enabled']) && $field['conditional-logic-enabled'] === 'yes') { $render_field = false; } } if( $render_field ){ $output_fields .= apply_filters('wppb_output_form_field_' . Wordpress_Creation_Kit_PB::wck_generate_slug($field['field']), '', $this->args['form_type'], $field, $this->wppb_get_desired_user_id(), $field_check_errors, $global_request, $this->args['role'], $this); $output_fields .= apply_filters('wppb_output_specific_error_message', $specific_message); } $output_fields .= apply_filters( 'wppb_output_after_form_field', '
  • ', $field, $this->args['ID'], $this->args['form_type'], $called_from ); } $output_fields .= apply_filters( 'wppb_output_after_last_form_field', '', $this->args['ID'], $this->args['form_type'], $called_from ); } return apply_filters( 'wppb_output_fields_filter', $output_fields ); } function wppb_add_send_credentials_checkbox ( $request_data, $form ){ if ( $form == 'edit_profile' ) echo ''; else{ $checkbox = apply_filters( 'wppb_send_credentials_checkbox_logic', '
  • ', $request_data, $form ); $wppb_general_settings = get_option( 'wppb_general_settings' ); echo ( isset( $wppb_general_settings['emailConfirmation'] ) && ( $wppb_general_settings['emailConfirmation'] == 'yes' ) ? '' : $checkbox ); } } function wppb_test_required_form_values( $global_request ){ $output_field_errors = array(); $form_fields = apply_filters( 'wppb_form_fields', $this->args['form_fields'], array( 'global_request' => $global_request, 'context' => 'validate_frontend', 'form_type' => $this->args['form_type'], 'role' => $this->args['role'], 'user_id' => $this->wppb_get_desired_user_id() ) ); if( !empty( $form_fields ) ){ foreach( $form_fields as $field ){ $error_for_field = apply_filters( 'wppb_check_form_field_'.Wordpress_Creation_Kit_PB::wck_generate_slug( $field['field'] ), '', $field, $global_request, $this->args['form_type'], $this->args['role'], $this->wppb_get_desired_user_id() ); if( !empty( $error_for_field ) ) $output_field_errors[$field['id']] = '' . $error_for_field . ''; } } return apply_filters( 'wppb_output_field_errors_filter', $output_field_errors, $this->args['form_fields'], $global_request, $this->args['form_type'] ); } function wppb_save_form_values( $global_request ){ $user_id = $this->wppb_get_desired_user_id(); $userdata = apply_filters( 'wppb_build_userdata', array(), $global_request, $this->args ); $new_user_signup = false; $wppb_general_settings = get_option( 'wppb_general_settings' ); if( $this->args['form_type'] == 'register' ){ $result = $this->wppb_register_user( $global_request, $userdata ); $user_id = $result['user_id']; $userdata = $result['userdata']; $new_user_signup = $result['new_user_signup']; }elseif( $this->args['form_type'] == 'edit_profile' ){ if( isset( $wppb_general_settings['loginWith'] ) && ( $wppb_general_settings['loginWith'] == 'email' ) ){ $user_info = get_userdata( $user_id ); $userdata['user_login'] = $user_info->user_login; } $userdata['ID'] = $this->wppb_get_desired_user_id(); $userdata = wp_unslash( $userdata ); /* if the user changes his password then we can't send it to the wp_update_user() function or the user will be logged out and won't be logged in again because we call wp_update_user() after the headers were sent( in the content as a shortcode ) */ if( isset( $userdata['user_pass'] ) && !empty( $userdata['user_pass'] ) ){ unset($userdata['user_pass']); } if( isset( $userdata['role'] ) && is_array( $userdata['role'] ) ) { $user_data = get_userdata( $user_id ); $user_data->remove_all_caps(); foreach( $userdata['role'] as $role ) { if( $role !== 'administrator' || $role !== 'super-admin' )//make sure this doesn't happen for any reason $user_data->add_role( $role ); } unset( $userdata['role'] ); } wp_update_user( $userdata ); } if( !empty( $this->args['form_fields'] ) && !$new_user_signup ){ foreach( $this->args['form_fields'] as $field ){ if( apply_filters( 'wppb_pre_save_form_field', true, $field, $user_id, $global_request, $this->args['form_type'] ) ) do_action( 'wppb_save_form_field', $field, $user_id, $global_request, $this->args['form_type'] ); } if ( $this->args['form_type'] == 'register' ){ if ( !is_wp_error( $user_id ) ){ $wppb_general_settings = get_option( 'wppb_general_settings' ); if( isset( $global_request['send_credentials_via_email'] ) && ( $global_request['send_credentials_via_email'] == 'sending' ) ) $send_credentials_via_email = 'sending'; else $send_credentials_via_email = ''; wppb_notify_user_registration_email( get_bloginfo( 'name' ), ( isset( $userdata['user_login'] ) ? trim( $userdata['user_login'] ) : trim( $userdata['user_email'] ) ), trim( $userdata['user_email'] ), $send_credentials_via_email, trim( $userdata['user_pass'] ), ( wppb_get_admin_approval_option_value() === 'yes' ? 'yes' : 'no' ) ); } } } return $user_id; } function wppb_register_user( $global_request, $userdata ){ $wppb_module_settings = get_option( 'wppb_module_settings' ); $wppb_general_settings = get_option( 'wppb_general_settings' ); $user_id = null; $new_user_signup = false; if( isset( $wppb_general_settings['loginWith'] ) && ( $wppb_general_settings['loginWith'] == 'email' ) ){ $userdata['user_login'] = apply_filters( 'wppb_generated_random_username', Wordpress_Creation_Kit_PB::wck_generate_slug( trim( $userdata['user_email'] ) ), $userdata['user_email'] ); } /* filter so we can bypass Email Confirmation on register */ $wppb_general_settings['emailConfirmation'] = apply_filters( 'wppb_email_confirmation_on_register', $wppb_general_settings['emailConfirmation'], $global_request ); if ( isset( $wppb_general_settings['emailConfirmation'] ) && ( $wppb_general_settings['emailConfirmation'] == 'yes' ) ){ $new_user_signup = true; $userdata = $this->wppb_add_custom_field_values( $global_request, $userdata, $this->args['form_fields'] ); if( ! isset( $userdata['role'] ) ) { $userdata['role'] = $this->args['role']; } $userdata['user_pass'] = wp_hash_password( $userdata['user_pass'] ); if( is_multisite() ){ /* since version 2.0.7 add this meta so we know on what blog the user registered */ $userdata['registered_for_blog_id'] = get_current_blog_id(); $userdata = wp_unslash( $userdata ); } wppb_signup_user( $userdata['user_login'], $userdata['user_email'], $userdata ); }else{ if( ! isset( $userdata['role'] ) ) { $userdata['role'] = $this->args['role']; } $userdata = wp_unslash( $userdata ); // change User Registered date and time according to timezone selected in WordPress settings $wppb_get_date = wppb_get_register_date(); if( isset( $wppb_get_date ) ) { $userdata['user_registered'] = $wppb_get_date; } // insert user to database $user_id = wp_insert_user( $userdata ); } return array( 'userdata' => $userdata, 'user_id' => $user_id, 'new_user_signup' => $new_user_signup ); } function wppb_add_custom_field_values( $global_request, $meta, $form_properties ){ $form_fields = apply_filters( 'wppb_form_fields', $this->args['form_fields'], array( 'meta' => $meta, 'global_request' => $global_request, 'context' => 'user_signup' ) ); if( !empty( $form_fields ) ){ foreach( $form_fields as $field ){ if( !empty( $field['meta-name'] ) ){ $posted_value = ( !empty( $global_request[$field['meta-name']] ) ? $global_request[$field['meta-name']] : '' ); $meta[$field['meta-name']] = apply_filters( 'wppb_add_to_user_signup_form_field_'.Wordpress_Creation_Kit_PB::wck_generate_slug( $field['field'] ), $posted_value, $field, $global_request ); } } } return apply_filters( 'wppb_add_to_user_signup_form_meta', $meta, $global_request, $this->args['role'] ); } /** * Function that returns the id for the current logged in user or for edit profile forms for administrator it can return the id of a selected user */ function wppb_get_desired_user_id(){ if( $this->args['form_type'] == 'edit_profile' ){ //only admins if( ( !is_multisite() && current_user_can( 'edit_users' ) ) || ( is_multisite() && current_user_can( 'manage_network' ) ) ) { if( isset( $_GET['edit_user'] ) && ! empty( $_GET['edit_user'] ) ){ return absint( $_GET['edit_user'] ); } } } return get_current_user_id(); } static function wppb_edit_profile_select_user_to_edit(){ $display_edit_users_dropdown = apply_filters( 'wppb_display_edit_other_users_dropdown', true ); if( !$display_edit_users_dropdown ) return; /* add a hard cap: if we have more than 5000 users don't display the dropdown for performance considerations */ $user_count = count_users(); if( $user_count['total_users'] > apply_filters( 'wppb_edit_other_users_count_limit', 5000 ) ) return; if( isset( $_GET['edit_user'] ) && ! empty( $_GET['edit_user'] ) ) $selected = absint( $_GET['edit_user'] ); else $selected = get_current_user_id(); $query_args['fields'] = array( 'ID', 'user_login', 'display_name' ); $query_args['role'] = apply_filters( 'wppb_edit_profile_user_dropdown_role', '' ); $users = get_users( apply_filters( 'wppb_edit_other_users_dropdown_query_args', $query_args ) ); if( !empty( $users ) ) { /* turn it in a select2 */ wp_enqueue_script( 'wppb_select2_js', WPPB_PLUGIN_URL .'assets/js/select2/select2.min.js', array( 'jquery' ), PROFILE_BUILDER_VERSION ); wp_enqueue_style( 'wppb_select2_css', WPPB_PLUGIN_URL .'assets/css/select2/select2.min.css', array(), PROFILE_BUILDER_VERSION ); wp_add_inline_script( 'wppb_select2_js', 'jQuery(".wppb-user-to-edit").change(function () {window.location.href = jQuery(this).val(); });jQuery(function(){jQuery(".wppb-user-to-edit").select2(); })' ); ?>

    '. apply_filters( 'wppb_no_users_to_edit_message', __( 'There are no other users to edit', 'profile-builder' ) ) .'

    '; } } function wppb_frontend_scripts(){ wp_enqueue_script( 'wppb_front_end_script', WPPB_PLUGIN_URL.'assets/js/script-front-end.js', array('jquery'), PROFILE_BUILDER_VERSION, true ); wp_print_scripts( 'wppb_front_end_script' ); } /** * Handle toString method * * @since 2.0 * * @return string $html html for the form. */ public function __toString() { try { ob_start(); $this->wppb_form_logic(); $html = ob_get_clean(); return "{$html}"; } catch (Exception $exception) { return __( 'Something went wrong. Please try again!', 'profile-builder'); } } } /* set action for automatic login after registration */ add_action( 'init', 'wppb_autologin_after_registration' ); function wppb_autologin_after_registration(){ if( isset( $_GET['autologin'] ) && isset( $_GET['uid'] ) ){ $uid = absint( $_GET['uid'] ); $nonce = $_REQUEST['_wpnonce']; $arr_params = array( 'autologin', 'uid', '_wpnonce' ); $current_page_url = remove_query_arg( $arr_params, wppb_curpageurl() ); if ( ! ( wp_verify_nonce( $nonce , 'autologin-'.$uid.'-'.(int)( time() / 60 ) ) || wp_verify_nonce( $nonce , 'autologin-'.$uid.'-'.(int)( time() / 60 ) - 1 ) ) ){ wp_redirect( $current_page_url ); exit; } else { wp_set_auth_cookie( $uid ); wp_redirect( $current_page_url ); exit; } } } PK:\,$qq$default-fields/password/password.phpnuW+A*' : '' ); if ( array_key_exists( $field['id'], $field_check_errors ) ) $error_mark = ''; $extra_attr = apply_filters( 'wppb_extra_attribute', '', $field, $form_location ); $output = ' '; if( ! empty( $item_description ) ) $output .= ''. $item_description .' '. wppb_password_length_text() .' '. wppb_password_strength_description() .''; else $output .= ''. wppb_password_length_text() .' '. wppb_password_strength_description() .''; /* if we have active the password strength checker */ $output .= wppb_password_strength_checker_html(); } return apply_filters( 'wppb_'.$form_location.'_password', $output, $form_location, $field, $user_id, $field_check_errors, $request_data ); } add_filter( 'wppb_output_form_field_default-password', 'wppb_password_handler', 10, 6 ); /* handle field validation */ function wppb_check_password_value( $message, $field, $request_data, $form_location ){ if ( $form_location == 'register' ){ if ( ( isset( $request_data['passw1'] ) && ( trim( $request_data['passw1'] ) == '' ) ) && ( $field['required'] == 'Yes' ) ) return wppb_required_field_error($field["field-title"]); elseif ( !isset( $request_data['passw1'] ) && ( $field['required'] == 'Yes' ) ) return wppb_required_field_error($field["field-title"]); } if ( trim( $request_data['passw1'] ) != '' ){ $wppb_generalSettings = get_option( 'wppb_general_settings' ); if( wppb_check_password_length( $request_data['passw1'] ) ) return '
    '. sprintf( __( "The password must have the minimum length of %s characters", "profile-builder" ), $wppb_generalSettings['minimum_password_length'] ); if( wppb_check_password_strength() ){ return '
    ' . sprintf( __( "The password must have a minimum strength of %s", "profile-builder" ), wppb_check_password_strength() ); } } return $message; } add_filter( 'wppb_check_form_field_default-password', 'wppb_check_password_value', 10, 4 ); /* handle field save */ function wppb_userdata_add_password( $userdata, $global_request, $form_args ){ if( wppb_field_exists_in_form( 'Default - Password', $form_args ) ) { if (isset($global_request['passw1']) && (trim($global_request['passw1']) != '')) $userdata['user_pass'] = trim($global_request['passw1']); } return $userdata; } add_filter( 'wppb_build_userdata', 'wppb_userdata_add_password', 10, 3 );PK:\>F F 2default-fields/password-repeat/password-repeat.phpnuW+A*' : '' ); if ( array_key_exists( $field['id'], $field_check_errors ) ) $error_mark = ''; $extra_attr = apply_filters( 'wppb_extra_attribute', '', $field, $form_location ); $output = ' '; if( !empty( $item_description ) ) $output .= ''.$item_description.''; } return apply_filters( 'wppb_'.$form_location.'_repeat_password', $output, $form_location, $field, $user_id, $field_check_errors, $request_data ); } add_filter( 'wppb_output_form_field_default-repeat-password', 'wppb_password_repeat_handler', 10, 6 ); /* handle field validation */ function wppb_check_repeat_password_value( $message, $field, $request_data, $form_location ){ if ( $form_location == 'register' ){ if ( ( isset( $request_data['passw2'] ) && ( trim( $request_data['passw2'] ) == '' ) ) && ( $field['required'] == 'Yes' ) ) return wppb_required_field_error($field["field-title"]); elseif ( !isset( $request_data['passw2'] ) && ( $field['required'] == 'Yes' ) ) return wppb_required_field_error($field["field-title"]); elseif ( isset( $request_data['passw1'] ) && isset( $request_data['passw2'] ) && ( trim( $request_data['passw1'] ) != trim( $request_data['passw2'] ) ) && ( $field['required'] == 'Yes' ) ) return __( "The passwords do not match", "profile-builder" ); }elseif ( $form_location == 'edit_profile' ){ if ( isset( $request_data['passw1'] ) && isset( $request_data['passw2'] ) && ( trim( $request_data['passw1'] ) != trim( $request_data['passw2'] ) ) ) return __( "The passwords do not match", "profile-builder" ); } return $message; } add_filter( 'wppb_check_form_field_default-repeat-password', 'wppb_check_repeat_password_value', 10, 4 );PK:\1UuUu&default-fields/recaptcha/recaptcha.phpnuW+A $value) { $req .= $key . '=' . urlencode(stripslashes($value)) . '&'; } // Cut the last '&' $req=substr($req, 0, strlen($req)-1); return $req; } /** * Submits an HTTP GET to a reCAPTCHA server * @param string $path * @param array $data */ function _wppb_submitHTTPGet($path, $data) { $req = _wppb_encodeQS($data); $response = wp_remote_get($path . $req); if ( ! is_wp_error( $response )) return $response["body"]; } /** * Gets the challenge HTML (javascript and non-javascript version). * This is called from the browser, and the resulting reCAPTCHA HTML widget * is embedded within the HTML form it was called from. * @param string $pubkey A public key for reCAPTCHA * @param string $error The error given by reCAPTCHA (optional, default is null) * @param boolean $use_ssl Should the request be made over ssl? (optional, default is false) * @return string - The HTML to be embedded in the user's form. */ function wppb_recaptcha_get_html ( $pubkey, $form_name='' ){ global $wppb_recaptcha_forms; // is the counter for the number of forms that have recaptcha so we always have unique ids on the element if( is_null( $wppb_recaptcha_forms ) ) $wppb_recaptcha_forms = 0; $wppb_recaptcha_forms++; $field = wppb_get_recaptcha_field(); if ( empty($pubkey) ) echo $errorMessage = ''. __("To use reCAPTCHA you must get an API key from", "profile-builder"). " https://www.google.com/recaptcha/admin/create

    "; // extra class needed for Invisible reCAPTCHA html $invisible_class = ''; if ( isset($field['recaptcha-type']) && ($field['recaptcha-type'] == 'invisible') ) { $invisible_class = 'wppb-invisible-recaptcha'; } // reCAPTCHA html for all forms and we make sure we have a unique id for v2 return '
    '; } /** * Add reCAPTCHA scripts to both front-end PB forms (with support for multiple forms) as well as Default WP forms */ function wppb_recaptcha_script_footer(){ $field = wppb_get_recaptcha_field(); /* if we do not have a recaptcha field don't do nothing */ if( empty( $field ) ) return; //we don't have jquery on the backend if( current_filter() != 'wp_footer' ) { wp_print_scripts('jquery'); }else if(!wp_script_is('jquery')){ wp_print_scripts('jquery'); } //get site key $pubkey = ''; if( isset( $field['public-key'] ) ) { $pubkey = trim( $field['public-key'] ); } // Check if we have a reCAPTCHA type if ( !isset($field['recaptcha-type']) ) $field['recaptcha-type'] = 'v2' ; /*for invisible recaptcha we have extra parameters and the selector is different. v2 is initialized on the id of the div that must be unique and invisible is on the submit button of the forms that have the div */ if( $field['recaptcha-type'] === 'invisible' ) { $callback_conditions = 'jQuery("input[type=\'submit\']", jQuery( ".wppb-recaptcha-element" ).closest("form") )'; $invisible_parameters = '"callback" : wppbInvisibleRecaptchaOnSubmit,"size": "invisible"'; }else { $callback_conditions = 'jQuery(".wppb-recaptcha-element")'; $invisible_parameters = ''; } echo ''; if( $field['recaptcha-type'] === 'invisible' ) { echo ''; } $lang = '&hl=en'; $locale = get_locale(); if(!empty($locale)) { $locale_parts = explode('_',$locale); $lang = '&hl='.urlencode($locale_parts[0]); } echo ''; } add_action('wp_footer', 'wppb_recaptcha_script_footer', 9999); add_action('login_footer', 'wppb_recaptcha_script_footer'); add_action('register_form', 'wppb_recaptcha_script_footer'); add_action('lost_password', 'wppb_recaptcha_script_footer'); /** * A wppb_ReCaptchaResponse is returned from wppb_recaptcha_check_answer() */ class wppb_ReCaptchaResponse { var $is_valid; } /** * Calls an HTTP POST function to verify if the user's answer was correct * @param string $privkey * @param string $remoteip * @param string $response * @return wppb_ReCaptchaResponse */ function wppb_recaptcha_check_answer ( $privkey, $remoteip, $response ){ if ( $remoteip == null || $remoteip == '' ) echo ''. __("For security reasons, you must pass the remote ip to reCAPTCHA!", "profile-builder") .'

    '; // Discard empty solution submissions if ($response == null || strlen($response) == 0) { $recaptchaResponse = new wppb_ReCaptchaResponse(); if( isset( $_POST['wppb_recaptcha_load_error'] ) && wp_verify_nonce( $_POST['wppb_recaptcha_load_error'], 'wppb_recaptcha_init_error' ) ) $recaptchaResponse->is_valid = true; else $recaptchaResponse->is_valid = false; return $recaptchaResponse; } $getResponse = _wppb_submitHTTPGet( "https://www.google.com/recaptcha/api/siteverify?", array ( 'secret' => $privkey, 'remoteip' => $remoteip, 'response' => $response ) ); $answers = json_decode($getResponse, true); $recaptchaResponse = new wppb_ReCaptchaResponse(); if (trim($answers ['success']) == true) { $recaptchaResponse->is_valid = true; } else { $recaptchaResponse->is_valid = false; } return $recaptchaResponse; } /* the function to display error message on the registration page */ function wppb_validate_captcha_response( $publickey, $privatekey ){ if (isset($_POST['g-recaptcha-response'])){ $recaptcha_response_field = $_POST['g-recaptcha-response']; } else { $recaptcha_response_field = ''; } $resp = wppb_recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $recaptcha_response_field ); if ( !empty( $_POST ) ) return ( ( !$resp->is_valid ) ? false : true ); } /* the function to add reCAPTCHA to the registration form of PB */ function wppb_recaptcha_handler ( $output, $form_location, $field, $user_id, $field_check_errors, $request_data ){ if ( $field['field'] == 'reCAPTCHA' ){ $item_title = apply_filters( 'wppb_'.$form_location.'_recaptcha_custom_field_'.$field['id'].'_item_title', wppb_icl_t( 'plugin profile-builder-pro', 'custom_field_'.$field['id'].'_title_translation', $field['field-title'] ) ); $item_description = wppb_icl_t( 'plugin profile-builder-pro', 'custom_field_'.$field['id'].'_description_translation', $field['description'] ); wppb_recaptcha_set_default_values(); if ( ($form_location == 'register') && ( isset($field['captcha-pb-forms']) ) && (strpos($field['captcha-pb-forms'],'pb_register') !== false) ) { $error_mark = ( ( $field['required'] == 'Yes' ) ? '*' : '' ); if ( array_key_exists( $field['id'], $field_check_errors ) ) $error_mark = ''; $publickey = trim( $field['public-key'] ); $privatekey = trim( $field['private-key'] ); if ( empty( $publickey ) || empty( $privatekey ) ) return ''.apply_filters( 'wppb_'.$form_location.'_recaptcha_custom_field_'.$field['id'].'_error_message', __("To use reCAPTCHA you must get an API public key from:", "profile-builder"). 'https://www.google.com/recaptcha/admin/create' ).''; if ( empty($field['recaptcha-type']) || ($field['recaptcha-type'] == 'v2') ) { $output = '' . wppb_recaptcha_get_html($publickey, 'pb_register'); if (!empty($item_description)) $output .= '' . $item_description . ''; } else { // html for Invisible reCAPTCHA $output = wppb_recaptcha_get_html($publickey, 'pb_register'); } return $output; } } } add_filter( 'wppb_output_form_field_recaptcha', 'wppb_recaptcha_handler', 10, 6 ); /* handle reCAPTCHA field validation on PB Register form */ function wppb_check_recaptcha_value( $message, $field, $request_data, $form_location ){ if( $field['field'] == 'reCAPTCHA' ){ if ( ( $form_location == 'register' ) && ( isset($field['captcha-pb-forms']) ) && (strpos($field['captcha-pb-forms'],'pb_register') !== false) ) { /* theme my login plugin executes the register_errors hook on the frontend on all pages so on our register forms we might have already a recaptcha response so do not verify it again or it will fail */ global $wppb_recaptcha_response; if (!isset($wppb_recaptcha_response)){ $wppb_recaptcha_response = wppb_validate_captcha_response( trim( $field['public-key'] ), trim( $field['private-key'] ) ); } if ( ( $wppb_recaptcha_response == false ) && ( $field['required'] == 'Yes' ) ){ return wppb_required_field_error($field["field-title"]); } } } return $message; } add_filter( 'wppb_check_form_field_recaptcha', 'wppb_check_recaptcha_value', 10, 4 ); // Get the reCAPTCHA field information function wppb_get_recaptcha_field(){ $wppb_manage_fields = get_option( 'wppb_manage_fields', 'not_found' ); $field = ''; if ( $wppb_manage_fields != 'not_found' ) { foreach ($wppb_manage_fields as $value) { if ($value['field'] == 'reCAPTCHA') $field = $value; } } return $field; } /* Display reCAPTCHA on PB Recover Password form */ function wppb_display_recaptcha_recover_password( $output ){ $field = wppb_get_recaptcha_field(); if ( !empty($field) ) { $publickey = trim($field['public-key']); $item_title = apply_filters('wppb_recover_password_recaptcha_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); // check where reCAPTCHA should display and add reCAPTCHA html if ( isset($field['captcha-pb-forms']) && ( strpos( $field['captcha-pb-forms'],'pb_recover_password' ) !== false ) ) { if ( empty($field['recaptcha-type']) || ($field['recaptcha-type'] == 'v2') ) { $recaptcha_output = '' . wppb_recaptcha_get_html($publickey, 'pb_recover_password'); if (!empty($item_description)) $recaptcha_output .= '' . $item_description . ''; $output = str_replace('', '
  • ' . $recaptcha_output . '
  • ' . '', $output); } else { // output Invisible reCAPTCHA html $output = str_replace('', '
  • ' . wppb_recaptcha_get_html($publickey, 'pb_recover_password') . '
  • ' . '', $output); } } } return $output; } add_filter('wppb_recover_password_generate_password_input','wppb_display_recaptcha_recover_password'); /* Function that changes the messageNo from the Recover Password form */ function wppb_recaptcha_change_recover_password_message_no($messageNo) { if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'recover_password') { $field = wppb_get_recaptcha_field(); if (!empty($field)) { global $wppb_recaptcha_response; if (!isset($wppb_recaptcha_response)) $wppb_recaptcha_response = wppb_validate_captcha_response( trim( $field['public-key'] ), trim( $field['private-key'] ) ); if ( isset($field['captcha-pb-forms']) && (strpos($field['captcha-pb-forms'], 'pb_recover_password') !== false) ) { if ( ($wppb_recaptcha_response == false ) && ( $field['required'] == 'Yes' ) ) $messageNo = ''; } } } return $messageNo; } add_filter('wppb_recover_password_message_no', 'wppb_recaptcha_change_recover_password_message_no'); /* Function that adds the reCAPTCHA error message on the Recover Password form */ function wppb_recaptcha_recover_password_displayed_message1( $message ) { $field = wppb_get_recaptcha_field(); if ( !empty($field) ){ global $wppb_recaptcha_response; if (!isset($wppb_recaptcha_response)) $wppb_recaptcha_response = wppb_validate_captcha_response( trim( $field['public-key'] ), trim( $field['private-key'] ) ); if ( isset($field['captcha-pb-forms']) && ( strpos( $field['captcha-pb-forms'],'pb_recover_password' ) !== false ) && ( $wppb_recaptcha_response == false )) { // This message is also altered by the plugin-compatibilities.php file, in regards to Captcha plugin ( function wppb_captcha_recover_password_displayed_message1 ) if (($message == '

    wppb_recaptcha_error

    ') || ($message == '

    wppb_captcha_error

    ')) $message = '

    ' . wppb_recaptcha_field_error($field["field-title"]) . '

    '; else $message = $message . '

    ' . wppb_recaptcha_field_error($field["field-title"]) . '

    '; } } return $message; } add_filter('wppb_recover_password_displayed_message1', 'wppb_recaptcha_recover_password_displayed_message1'); /* Function that changes the default success message to wppb_recaptcha_error if the reCAPTCHA doesn't validate so that we can change the message displayed with the wppb_recover_password_displayed_message1 filter */ function wppb_recaptcha_recover_password_sent_message_1($message) { if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'recover_password') { $field = wppb_get_recaptcha_field(); if (!empty($field)) { global $wppb_recaptcha_response; if (!isset($wppb_recaptcha_response)) $wppb_recaptcha_response = wppb_validate_captcha_response( trim( $field['public-key'] ), trim( $field['private-key'] ) ); if ( isset($field['captcha-pb-forms']) && ( strpos($field['captcha-pb-forms'], 'pb_recover_password') !== false ) && ( $wppb_recaptcha_response == false ) ){ $message = 'wppb_recaptcha_error'; } } } return $message; } add_filter('wppb_recover_password_sent_message1', 'wppb_recaptcha_recover_password_sent_message_1'); /* Display reCAPTCHA html on PB Login form */ function wppb_display_recaptcha_login_form($form_part, $args) { if( !isset( $args['form_id'] ) || $args['form_id'] != 'wppb-loginform' ) return $form_part; $field = wppb_get_recaptcha_field(); if ( !empty($field) ) { $item_title = apply_filters('wppb_login_recaptcha_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); if ( isset($field['captcha-pb-forms']) && ( strpos( $field['captcha-pb-forms'],'pb_login' ) !== false ) ) { // check where reCAPTCHA should display and add reCAPTCHA html if ( empty($field['recaptcha-type']) || ($field['recaptcha-type'] == 'v2') ) { $recaptcha_output = '' . wppb_recaptcha_get_html(trim($field['public-key']), 'pb_login'); if (!empty($item_description)) $recaptcha_output .= '' . $item_description . ''; $form_part .= '
    ' . $recaptcha_output . '
    '; } else { //output Invisible reCAPTCHA html $form_part .= wppb_recaptcha_get_html(trim($field['public-key']), 'pb_login'); } } } return $form_part; } add_filter('login_form_middle', 'wppb_display_recaptcha_login_form', 10, 2); /* Display reCAPTCHA html on default WP Login form */ function wppb_display_recaptcha_wp_login_form(){ $field = wppb_get_recaptcha_field(); if ( !empty($field) ) { $item_title = apply_filters('wppb_login_recaptcha_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); if ( isset($field['captcha-wp-forms']) && (strpos( $field['captcha-wp-forms'],'default_wp_login' ) !== false) ) { // check where reCAPTCHA should display and add reCAPTCHA html if ( empty($field['recaptcha-type']) || ($field['recaptcha-type'] == 'v2') ) { $recaptcha_output = '' . wppb_recaptcha_get_html(trim($field['public-key'])); if (!empty($item_description)) $recaptcha_output .= '' . $item_description . ''; echo '
    ' . $recaptcha_output . '
    '; } else { // output Invisible reCAPTCHA html echo wppb_recaptcha_get_html( trim($field['public-key'])); } } } } add_action( 'login_form', 'wppb_display_recaptcha_wp_login_form' ); //Show reCAPTCHA error on Login form (both default and PB one) function wppb_recaptcha_login_wp_error_message($user){ //make sure you're on a Login form (WP or PB) if ( isset( $_POST['wp-submit'] ) && !is_wp_error($user) && !isset( $_POST['pms_login'] ) ) { $field = wppb_get_recaptcha_field(); if ( !empty($field) ){ global $wppb_recaptcha_response; if (!isset($wppb_recaptcha_response)) $wppb_recaptcha_response = wppb_validate_captcha_response( trim( $field['public-key'] ), trim( $field['private-key'] ) ); //reCAPTCHA error for displaying on the PB login form if ( isset($_POST['wppb_login']) && ($_POST['wppb_login'] == true) ) { // it's a PB login form, check if we have a reCAPTCHA on it and display error if not valid if ((isset($field['captcha-pb-forms'])) && (strpos($field['captcha-pb-forms'], 'pb_login') !== false) && ($wppb_recaptcha_response == false)) { $user = new WP_Error('wppb_recaptcha_error', __('Please enter a (valid) reCAPTCHA value', 'profile-builder')); remove_filter( 'authenticate', 'wp_authenticate_username_password', 20, 3 ); remove_filter( 'authenticate', 'wp_authenticate_email_password', 20, 3 ); } } else { //reCAPTCHA error for displaying on the default WP login form if (isset($field['captcha-wp-forms']) && (strpos($field['captcha-wp-forms'], 'default_wp_login') !== false) && ($wppb_recaptcha_response == false)) { $user = new WP_Error('wppb_recaptcha_error', __('Please enter a (valid) reCAPTCHA value', 'profile-builder')); remove_filter( 'authenticate', 'wp_authenticate_username_password', 20, 3 ); remove_filter( 'authenticate', 'wp_authenticate_email_password', 20, 3 ); } } } } return $user; } add_filter('authenticate','wppb_recaptcha_login_wp_error_message', 9); // Display reCAPTCHA html on default WP Recover Password form function wppb_display_recaptcha_default_wp_recover_password() { $field = wppb_get_recaptcha_field(); if (!empty($field)) { $publickey = trim($field['public-key']); $item_title = apply_filters('wppb_recover_password_recaptcha_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); if ( isset($field['captcha-wp-forms']) && (strpos( $field['captcha-wp-forms'], 'default_wp_recover_password') !== false) ) { // check where reCAPTCHA should display and add reCAPTCHA html if ( empty($field['recaptcha-type']) || ($field['recaptcha-type'] == 'v2') ){ $recaptcha_output = '' . wppb_recaptcha_get_html($publickey); if (!empty($item_description)) $recaptcha_output .= '' . $item_description . ''; echo '
    ' . $recaptcha_output . '
    '; } else { // output Invisible reCAPTCHA html echo wppb_recaptcha_get_html($publickey); } } } } add_action('lostpassword_form','wppb_display_recaptcha_default_wp_recover_password'); // Verify and show reCAPTCHA errors for default WP Recover Password function wppb_verify_recaptcha_default_wp_recover_password(){ // If field 'username or email' is empty - return if( isset( $_REQUEST['user_login'] ) && "" == $_REQUEST['user_login'] ) return; $field = wppb_get_recaptcha_field(); if ( !empty($field) ){ global $wppb_recaptcha_response; if (!isset($wppb_recaptcha_response)) $wppb_recaptcha_response = wppb_validate_captcha_response( trim( $field['public-key'] ), trim( $field['private-key'] ) ); // If reCAPTCHA not entered or incorrect reCAPTCHA answer if ( isset( $_REQUEST['g-recaptcha-response'] ) && ( ( "" == $_REQUEST['g-recaptcha-response'] ) || ( $wppb_recaptcha_response == false ) ) ) { wp_die( __('Please enter a (valid) reCAPTCHA value','profile-builder') . '
    ' . __( "Click the BACK button on your browser, and try again.", 'profile-builder' ) ) ; } } } add_action('lostpassword_post','wppb_verify_recaptcha_default_wp_recover_password'); /* Display reCAPTCHA html on default WP Register form */ function wppb_display_recaptcha_default_wp_register(){ $field = wppb_get_recaptcha_field(); if (!empty($field)) { $publickey = trim($field['public-key']); $item_title = apply_filters('wppb_register_recaptcha_custom_field_' . $field['id'] . '_item_title', wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_title_translation', $field['field-title'])); $item_description = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $field['id'] . '_description_translation', $field['description']); wppb_recaptcha_set_default_values(); if (isset($field['captcha-wp-forms']) && (strpos($field['captcha-wp-forms'], 'default_wp_register') !== false)) { // check where reCAPTCHA should display and add reCAPTCHA html if ( empty($field['recaptcha-type']) || ($field['recaptcha-type'] == 'v2') ) { $recaptcha_output = '' . wppb_recaptcha_get_html($publickey); if (!empty($item_description)) $recaptcha_output .= '' . $item_description . ''; echo '
    ' . $recaptcha_output . '
    '; } else { // output reCAPTCHA html echo wppb_recaptcha_get_html($publickey); } } } } add_action( 'register_form', 'wppb_display_recaptcha_default_wp_register' ); // Verify and show reCAPTCHA errors for default WP Register form function wppb_verify_recaptcha_default_wp_register( $errors ){ $field = wppb_get_recaptcha_field(); if ( !empty($field) ){ global $wppb_recaptcha_response; if (!isset($wppb_recaptcha_response)) $wppb_recaptcha_response = wppb_validate_captcha_response( trim( $field['public-key'] ), trim( $field['private-key'] ) ); // If reCAPTCHA not entered or incorrect reCAPTCHA answer if ( isset( $_REQUEST['g-recaptcha-response'] ) && ( ( "" == $_REQUEST['g-recaptcha-response'] ) || ( $wppb_recaptcha_response == false ) ) ) { $errors->add( 'wppb_recaptcha_error', __('Please enter a (valid) reCAPTCHA value','profile-builder') ); } } return $errors; } add_filter('registration_errors','wppb_verify_recaptcha_default_wp_register'); // set default values in case there's already an existing reCAPTCHA field in Manage fields (when upgrading) function wppb_recaptcha_set_default_values() { $manage_fields = get_option('wppb_manage_fields', 'not_set'); if ($manage_fields != 'not_set') { foreach ($manage_fields as $key => $value) { if ($value['field'] == 'reCAPTCHA') { if ( !isset($value['captcha-pb-forms']) ) $manage_fields[$key]['captcha-pb-forms'] = 'pb_register'; if ( !isset($value['captcha-wp-forms']) ) $manage_fields[$key]['captcha-wp-forms'] = 'default_wp_register'; if ( !isset($value['recaptcha-type']) ) $manage_fields[$key]['recaptcha-type'] = 'v2'; } } update_option('wppb_manage_fields', $manage_fields); } } PK:\5w *default-fields/gdpr-delete/gdpr-delete.phpnuW+A'. wp_kses_post( $item_title ) .' '; $output .= ''.trim( html_entity_decode ( $item_description ) ).''; $delete_url = add_query_arg( array( 'wppb_user' => $edited_user_id, 'wppb_action' => 'wppb_delete_user', 'wppb_nonce' => wp_create_nonce( 'wppb-user-own-account-deletion'), ), home_url()); wp_enqueue_script( 'wppb-gdpr-delete-script', WPPB_PLUGIN_URL.'front-end/default-fields/gdpr-delete/gdpr-delete.js', array('jquery'), PROFILE_BUILDER_VERSION, true ); wp_localize_script('wppb-gdpr-delete-script', 'wppbGdpr', array( 'delete_url' => $delete_url, 'delete_text' => sprintf(__('Type %s to confirm deleting your account and all data associated with it:', 'profile-builder'), 'DELETE' ), 'delete_error_text' => sprintf(__('You did not type %s. Try again!', 'profile-builder'), 'DELETE' ), )); return apply_filters( 'wppb_'.$form_location.'_gdpr_delete_custom_field_'.$field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data ); } } } add_filter( 'wppb_output_form_field_gdpr-delete-button', 'wppb_gdpr_delete_handler', 10, 6 ); PK:\9Zr)default-fields/gdpr-delete/gdpr-delete.jsnuW+AjQuery(document).ready(function() { jQuery(".wppb-delete-account").on("click", function (e) { e.preventDefault(); var wppbDeleteUser = prompt(wppbGdpr.delete_text); if( wppbDeleteUser === "DELETE" ) { window.location.replace(wppbGdpr.delete_url); } else{ alert( wppbGdpr.delete_error_text ); } }); });PK:\t++&default-fields/user-role/user-role.phpnuW+Aroles ) ) { $user_role = $user_data->roles[0]; $user_roles = $user_data->roles; } if( isset( $user_data->allcaps['manage_options'] ) && $user_data->allcaps['manage_options'] == 1 ) { $user_can_manage_options = true; } } $input_value = isset( $request_data['custom_field_user_role'] ) ? $request_data['custom_field_user_role'] : $user_role; $input_value_multiple = isset( $request_data['custom_field_user_role'] ) ? $request_data['custom_field_user_role'] : $user_roles; $item_title = apply_filters( 'wppb_'.$form_location.'_user_role_custom_field_'.$field['id'].'_item_title', wppb_icl_t( 'plugin profile-builder-pro', 'custom_field_'.$field['id'].'_title_translation', $field['field-title'] ) ); $item_description = wppb_icl_t( 'plugin profile-builder-pro', 'custom_field_'.$field['id'].'_description_translation', $field['description'] ); //get user roles if( !empty( $field['user-roles'] ) ) { global $wp_roles; $available_user_roles = explode( ', ', $field['user-roles'] ); foreach( $available_user_roles as $key => $role_slug ) { if( isset( $wp_roles->roles[$role_slug]['name'] ) ) { $available_user_roles[$key] = array( 'slug' => $role_slug, 'name' => $wp_roles->roles[$role_slug]['name'] ); } else { unset( $available_user_roles[$key] ); } } } $extra_attr = apply_filters( 'wppb_extra_attribute', '', $field, $form_location ); if( $form_location == 'register' || ( $form_location == 'edit_profile' && current_user_can('manage_options') && $user_can_manage_options == false ) || ( $show_user_role_on_edit_profile && !current_user_can('manage_options') ) ) { $error_mark = ( ( $field['required'] == 'Yes' ) ? '*' : '' ); if ( array_key_exists( $field['id'], $field_check_errors ) ) $error_mark = ''; $output = ' '; if( $form_location == 'edit_profile' && !$show_user_role_on_edit_profile ) $output .= ''. __( 'Only administrators can see this field on edit profile forms.', 'profile-builder' ) .''; if( !empty( $item_description ) ) $output .= ''.$item_description.''; } elseif( $form_location == 'edit_profile' && current_user_can('manage_options') && $user_can_manage_options == true ) { $output = '

    ' . __( 'As an administrator you cannot change your role.', 'profile-builder' ) . '

    '; $output .= ''; if( !$show_user_role_on_edit_profile ) $output .= ''. __( 'Only administrators can see this field on edit profile forms.', 'profile-builder' ) .''; if( !empty( $item_description ) ) $output .= ''.$item_description.''; } else{ if( !empty( $input_value_multiple ) ){ foreach( $input_value_multiple as $input_value_multi ){ $output .= ''; } } else { $output .= ''; } } return apply_filters( 'wppb_'.$form_location.'_user_role_custom_field_'.$field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data, $input_value, $input_value_multiple ); } } add_filter( 'wppb_output_form_field_select-user-role', 'wppb_user_role_handler', 10, 6 ); /* handle field validation */ function wppb_check_user_role_value( $message, $field, $request_data, $form_location ) { if( $form_location == 'edit_profile' && isset($field['user-roles-on-edit-profile']) && $field['user-roles-on-edit-profile'] === 'yes' ) $show_user_role_on_edit_profile = true; else $show_user_role_on_edit_profile = false; $field['meta-name'] = 'custom_field_user_role'; if( $form_location == 'back_end' ) return $message; if( $form_location == 'edit_profile' && ( ( !current_user_can( 'manage_options' ) && ( isset( $request_data[wppb_handle_meta_name( $field['meta-name'] )] ) ) ) && !$show_user_role_on_edit_profile ) ) return __( 'You cannot register this user role', 'profile-builder'); $roles_editor_active = false; $wppb_generalSettings = get_option( 'wppb_general_settings', 'not_found' ); if( $wppb_generalSettings != 'not_found' ) { if( ! empty( $wppb_generalSettings['rolesEditor'] ) && ( $wppb_generalSettings['rolesEditor'] == 'yes' ) && $form_location == 'edit_profile' && current_user_can('manage_options') ) { $roles_editor_active = true; } } if( $field['field'] == 'Select (User Role)' ){ if( ( $form_location == 'register' || $show_user_role_on_edit_profile ) && $field['required'] == 'Yes' && current_user_can( 'manage_options' ) === false ) { if( ( isset( $request_data[wppb_handle_meta_name( $field['meta-name'] )] ) && ( trim( $request_data[wppb_handle_meta_name( $field['meta-name'] )] ) == '' ) ) || !isset( $request_data[wppb_handle_meta_name( $field['meta-name'] )] ) ){ return wppb_required_field_error($field["field-title"]); } } if( isset( $field['user-roles'] ) && isset( $request_data['custom_field_user_role'] ) ) { $available_user_roles = explode(', ', $field['user-roles'] ); if( $roles_editor_active && is_array( $request_data['custom_field_user_role'] ) ) { foreach( $request_data['custom_field_user_role'] as $key => $value ) { if( ! in_array( $value, $available_user_roles ) ) { return __( 'You cannot register this user role', 'profile-builder'); } } } else { if( ! in_array( $request_data['custom_field_user_role'], $available_user_roles ) ) { return __( 'You cannot register this user role', 'profile-builder'); } } } } return $message; } add_filter( 'wppb_check_form_field_select-user-role', 'wppb_check_user_role_value', 10, 4 ); /* handle field save */ function wppb_userdata_add_user_role( $userdata, $global_request, $form_args ){ if( wppb_field_exists_in_form( 'Select (User Role)', $form_args ) ) { $roles_editor_active = false; $wppb_generalSettings = get_option('wppb_general_settings', 'not_found'); if ($wppb_generalSettings != 'not_found') { if (!empty($wppb_generalSettings['rolesEditor']) && $wppb_generalSettings['rolesEditor'] === 'yes' && current_user_can('manage_options')) { $roles_editor_active = true; } } if (isset($global_request['custom_field_user_role'])) { if ($roles_editor_active && is_array($global_request['custom_field_user_role'])) { $user_roles = array_map('trim', $global_request['custom_field_user_role']); $user_roles = array_map('sanitize_text_field', $user_roles); //don't allow administrator value. it should never be here but just in case make a hard check if (($key = array_search("administrator", $user_roles)) !== false) { unset($user_roles[$key]); } $userdata['role'] = $user_roles; } else { $role = sanitize_text_field(trim($global_request['custom_field_user_role'])); if( $role !== 'administrator' ) {//don't allow administrator value. it should never be here but just in case make a hard check $userdata['role'] = $role; } } } } return $userdata; } add_filter( 'wppb_build_userdata', 'wppb_userdata_add_user_role', 10, 3 );PK:\v2 &default-fields/last-name/last-name.phpnuW+A*' : '' ); if ( array_key_exists( $field['id'], $field_check_errors ) ) $error_mark = ''; $extra_attr = apply_filters( 'wppb_extra_attribute', '', $field, $form_location ); $output = ' '; if( !empty( $item_description ) ) $output .= ''. $item_description .''; } return apply_filters( 'wppb_'.$form_location.'_lastname', $output, $form_location, $field, $user_id, $field_check_errors, $request_data ); } add_filter( 'wppb_output_form_field_default-last-name', 'wppb_last_name_handler', 10, 6 ); /* handle field validation */ function wppb_check_last_name_value( $message, $field, $request_data, $form_location ){ if( $field['required'] == 'Yes' ){ if( ( isset( $request_data['last_name'] ) && ( trim( $request_data['last_name'] ) == '' ) ) || !isset( $request_data['last_name'] ) ){ return wppb_required_field_error($field["field-title"]); } } return $message; } add_filter( 'wppb_check_form_field_default-last-name', 'wppb_check_last_name_value', 10, 4 ); /* handle field save */ function wppb_userdata_add_last_name( $userdata, $global_request, $form_args ){ if( wppb_field_exists_in_form( 'Default - Last Name', $form_args ) ) { if (isset($global_request['last_name'])) $userdata['last_name'] = sanitize_text_field(trim($global_request['last_name'])); } return $userdata; } add_filter( 'wppb_build_userdata', 'wppb_userdata_add_last_name', 10, 3 );PK:\. . default-fields/jabber/jabber.phpnuW+A*' : '' ); if ( array_key_exists( $field['id'], $field_check_errors ) ) $error_mark = ''; $extra_attr = apply_filters( 'wppb_extra_attribute', '', $field, $form_location ); $output = ' '; if( !empty( $item_description ) ) $output .= ''. $item_description .''; } return apply_filters( 'wppb_'.$form_location.'_jabber', $output, $form_location, $field, $user_id, $field_check_errors, $request_data ); } add_filter( 'wppb_output_form_field_default-jabber-google-talk', 'wppb_jabber_handler', 10, 6 ); /* handle field validation */ function wppb_check_jabber_value( $message, $field, $request_data, $form_location ){ if( $field['required'] == 'Yes' ){ if( ( isset( $request_data['jabber'] ) && ( trim( $request_data['jabber'] ) == '' ) ) || !isset( $request_data['jabber'] ) ){ return wppb_required_field_error($field["field-title"]); } } return $message; } add_filter( 'wppb_check_form_field_default-jabber-google-talk', 'wppb_check_jabber_value', 10, 4 ); /* handle field save */ function wppb_userdata_add_jabber( $userdata, $global_request ){ if ( isset( $global_request['jabber'] ) ) $userdata['jabber'] = sanitize_text_field( trim( $global_request['jabber'] ) ); return $userdata; } add_filter( 'wppb_build_userdata', 'wppb_userdata_add_jabber', 10, 2 );PK:\ޒdefault-fields/email/email.phpnuW+A*' : '' ); if ( array_key_exists( $field['id'], $field_check_errors ) ) $error_mark = ''; $extra_attr = apply_filters( 'wppb_extra_attribute', '', $field, $form_location ); $output = ' '; if( !empty( $item_description ) ) $output .= ''. $item_description .''; } return apply_filters( 'wppb_'.$form_location.'_email', $output, $form_location, $field, $user_id, $field_check_errors, $request_data ); } add_filter( 'wppb_output_form_field_default-e-mail', 'wppb_email_handler', 10, 6 ); /* handle field validation */ function wppb_check_email_value( $message, $field, $request_data, $form_location ){ global $wpdb; // apply filter to allow stripping slashes if necessary $request_data['email'] = apply_filters( 'wppb_before_processing_email_from_forms', $request_data['email'] ); if ( ( isset( $request_data['email'] ) && ( trim( $request_data['email'] ) == '' ) ) && ( $field['required'] == 'Yes' ) ) return wppb_required_field_error($field["field-title"]); if ( isset( $request_data['email'] ) && !is_email( trim( $request_data['email'] ) ) ){ return __( 'The email you entered is not a valid email address.', 'profile-builder' ); } if ( empty( $request_data['email'] ) ) { return __( 'You must enter a valid email address.', 'profile-builder' ); } $wppb_generalSettings = get_option( 'wppb_general_settings' ); if ( isset( $wppb_generalSettings['emailConfirmation'] ) && ( $wppb_generalSettings['emailConfirmation'] == 'yes' ) ){ $user_signup = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM ".$wpdb->base_prefix."signups WHERE user_email = %s AND active=0", $request_data['email'] ) ); if ( !empty( $user_signup ) ){ if ( $form_location == 'register' ){ return __( 'This email is already reserved to be used soon.', 'profile-builder' ) .'
    '. __( 'Please try a different one!', 'profile-builder' ); } else if ( $form_location == 'edit_profile' ){ $current_user = wp_get_current_user(); if( ! current_user_can( 'edit_users' ) ) { if ( $current_user->user_email != $request_data['email'] ) return __( 'This email is already reserved to be used soon.', 'profile-builder' ) .'
    '. __( 'Please try a different one!', 'profile-builder' ); } } } } $users = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->users} WHERE user_email = %s", $request_data['email'] ) ); if ( !empty( $users ) ){ if ( $form_location == 'register' ) return __( 'This email is already in use.', 'profile-builder' ) .'
    '. __( 'Please try a different one!', 'profile-builder' ); if ( $form_location == 'edit_profile' ){ $url_parts = parse_url( $_SERVER['HTTP_REFERER'] ); if( isset( $url_parts['query'] ) ) { parse_str( $url_parts['query'], $query ); } if( isset( $_GET['edit_user'] ) && ! empty( $_GET['edit_user'] ) ) { $current_user_id = absint( $_GET['edit_user'] ); } elseif( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $query['edit_user'] ) && ! empty( $query['edit_user'] ) ) { $current_user_id = $query['edit_user']; } else { $current_user = wp_get_current_user(); $current_user_id = $current_user->ID; } foreach ( $users as $user ) if ( $user->ID != $current_user_id ) return __( 'This email is already in use.', 'profile-builder' ) .'
    '. __( 'Please try a different one!', 'profile-builder' ); } } return $message; } add_filter( 'wppb_check_form_field_default-e-mail', 'wppb_check_email_value', 10, 4 ); /* handle field save */ function wppb_userdata_add_email( $userdata, $global_request, $form_args ){ if( wppb_field_exists_in_form( 'Default - E-mail', $form_args ) ) { // apply filter to allow stripping slashes if necessary if (isset($global_request['email'])) { $global_request['email'] = apply_filters('wppb_before_processing_email_from_forms', $global_request['email']); $userdata['user_email'] = sanitize_text_field(trim($global_request['email'])); } } return $userdata; } add_filter( 'wppb_build_userdata', 'wppb_userdata_add_email', 10, 3 );PK:\EB default-fields/aim/aim.phpnuW+A*' : '' ); if ( array_key_exists( $field['id'], $field_check_errors ) ) $error_mark = ''; $extra_attr = apply_filters( 'wppb_extra_attribute', '', $field, $form_location ); $output = ' '; if( !empty( $item_description ) ) $output .= ''. $item_description .''; } return apply_filters( 'wppb_'.$form_location.'_aim', $output, $form_location, $field, $user_id, $field_check_errors, $request_data ); } add_filter( 'wppb_output_form_field_default-aim', 'wppb_aim_handler', 10, 6 ); /* handle field validation */ function wppb_check_aim_value( $message, $field, $request_data, $form_location ){ if( $field['required'] == 'Yes' ){ if( ( isset( $request_data['aim'] ) && ( trim( $request_data['aim'] ) == '' ) ) || !isset( $request_data['aim'] ) ){ return wppb_required_field_error($field["field-title"]); } } return $message; } add_filter( 'wppb_check_form_field_default-aim', 'wppb_check_aim_value', 10, 4 ); /* handle field save */ function wppb_userdata_add_aim( $userdata, $global_request ){ if ( isset( $global_request['aim'] ) ) $userdata['aim'] = sanitize_text_field ( trim( $global_request['aim'] ) ); return $userdata; } add_filter( 'wppb_build_userdata', 'wppb_userdata_add_aim', 10, 2 );PK:\ "$default-fields/username/username.phpnuW+A*' : '' ); if ( array_key_exists( $field['id'], $field_check_errors ) ) $error_mark = ''; $readonly = ( ( $form_location == 'edit_profile' ) ? ' disabled="disabled"' : '' ); $extra_attr = apply_filters( 'wppb_extra_attribute', '', $field, $form_location ); $output = ' '; if( !empty( $item_description ) ) $output .= ''.$item_description.''; } return apply_filters( 'wppb_'.$form_location.'_username', $output, $form_location, $field, $user_id, $field_check_errors, $request_data ); } add_filter( 'wppb_output_form_field_default-username', 'wppb_username_handler', 10, 6 ); /* handle field validation */ function wppb_check_username_value( $message, $field, $request_data, $form_location ){ global $wpdb; if( $field['required'] == 'Yes' ){ if( ( isset( $request_data['username'] ) && ( trim( $request_data['username'] ) == '' ) ) || ( $form_location == 'register' && !isset( $request_data['username'] ) ) ){ return wppb_required_field_error($field["field-title"]); } } if( !empty( $request_data['username'] ) ){ if( $form_location == 'register' ) { if( username_exists($request_data['username'] ) ){ return __('This username already exists.', 'profile-builder') . '
    ' . __('Please try a different one!', 'profile-builder'); } if (!validate_username($request_data['username'])) { return __('This username is invalid because it uses illegal characters.', 'profile-builder') . '
    ' . __('Please enter a valid username.', 'profile-builder'); } } $wppb_generalSettings = get_option('wppb_general_settings'); if ( $wppb_generalSettings['emailConfirmation'] == 'yes' ){ if( is_multisite() && $request_data['username'] != preg_replace( '/\s+/', '', $request_data['username'] ) ){ return __( 'This username is invalid because it uses illegal characters.', 'profile-builder' ) .'
    '. __( 'Please enter a valid username.', 'profile-builder' ); } $userSignup = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM ".$wpdb->prefix."signups WHERE user_login = %s", $request_data['username'] ) ); if ( !empty( $userSignup ) ){ return __( 'This username is already reserved to be used soon.', 'profile-builder') .'
    '. __( 'Please try a different one!', 'profile-builder' ); } } } return $message; } add_filter( 'wppb_check_form_field_default-username', 'wppb_check_username_value', 10, 4 ); /* handle field save */ function wppb_userdata_add_username( $userdata, $global_request, $form_args ){ if( wppb_field_exists_in_form( 'Default - Username', $form_args ) ) { if (isset($global_request['username'])) $userdata['user_login'] = sanitize_user(trim($global_request['username'])); } return $userdata; } add_filter( 'wppb_build_userdata', 'wppb_userdata_add_username', 10, 3 );PK:\b *default-fields/description/description.phpnuW+Adescription; } if ( trim( $input_value ) == '' ) $input_value = $field['default-content']; $input_value = ( isset( $request_data['description'] ) ? trim( $request_data['description'] ) : $input_value ); $extra_attr = apply_filters( 'wppb_extra_attribute', '', $field, $form_location ); if ( $form_location != 'back_end' ){ $error_mark = ( ( $field['required'] == 'Yes' ) ? '*' : '' ); if ( array_key_exists( $field['id'], $field_check_errors ) ) $error_mark = ''; $output = ' '; if( !empty( $item_description ) ) $output .= ''. $item_description .''; } return apply_filters( 'wppb_'.$form_location.'_description', $output, $form_location, $field, $user_id, $field_check_errors, $request_data ); } add_filter( 'wppb_output_form_field_default-biographical-info', 'wppb_description_handler', 10, 6 ); /* handle field validation */ function wppb_check_description_value( $message, $field, $request_data, $form_location ){ if( $field['required'] == 'Yes' ){ if( ( isset( $request_data['description'] ) && ( trim( $request_data['description'] ) == '' ) ) || !isset( $request_data['description'] ) ){ return wppb_required_field_error($field["field-title"]); } } return $message; } add_filter( 'wppb_check_form_field_default-biographical-info', 'wppb_check_description_value', 10, 4 ); /* handle field save */ function wppb_userdata_add_description( $userdata, $global_request, $form_args ){ if( wppb_field_exists_in_form( 'Default - Biographical Info', $form_args ) ) { if (isset($global_request['description'])) { $description = apply_filters('pre_user_description', trim($global_request['description'])); $userdata['description'] = $description; } } return $userdata; } add_filter( 'wppb_build_userdata', 'wppb_userdata_add_description', 10, 3 );PK:\D#O~ ~ !default-fields/default-fields.phpnuW+A*' : '' ); if ( array_key_exists( $field['id'], $field_check_errors ) ) $error_mark = ''; $extra_attr = apply_filters( 'wppb_extra_attribute', '', $field, $form_location ); $output = ' '; if( !empty( $item_description ) ) $output .= ''. $item_description .''; return apply_filters( 'wppb_'.$form_location.'_nickname', $output, $form_location, $field, $user_id, $field_check_errors, $request_data ); } } add_filter( 'wppb_output_form_field_default-nickname', 'wppb_nickname_handler', 10, 6 ); /* handle field validation */ function wppb_check_nickname_value( $message, $field, $request_data, $form_location ){ if( $field['required'] == 'Yes' ){ if( ( isset( $request_data['nickname'] ) && ( trim( $request_data['nickname'] ) == '' ) ) || !isset( $request_data['nickname'] ) ){ return wppb_required_field_error($field["field-title"]); } } return $message; } add_filter( 'wppb_check_form_field_default-nickname', 'wppb_check_nickname_value', 10, 4 ); /* handle field save */ function wppb_userdata_add_nickname( $userdata, $global_request, $form_args ){ if( wppb_field_exists_in_form( 'Default - Nickname', $form_args ) ) { if (isset($global_request['nickname'])) $userdata['nickname'] = sanitize_text_field(trim($global_request['nickname'])); } return $userdata; } add_filter( 'wppb_build_userdata', 'wppb_userdata_add_nickname', 10, 3 );PK:\*))(default-fields/headings/contact-info.phpnuW+A'.$item_title.''.$item_description.''; return apply_filters( 'wppb_'.$form_location.'_default_heading_contact_info_'.$field['id'], $ret_custom_field, $form_location, $field, $user_id, $field_check_errors, $request_data ); } } add_filter( 'wppb_output_form_field_default-contact-info-heading', 'wppb_default_contact_info_handler', 10, 6 ); PK:\|((*default-fields/headings/about-yourself.phpnuW+A'.$item_title.''.$item_description.''; return apply_filters( 'wppb_'.$form_location.'_default_heading_about_yourself_'.$field['id'], $output, $form_location, $field, $user_id, $field_check_errors, $request_data ); } } add_filter( 'wppb_output_form_field_default-about-yourself-heading', 'wppb_default_about_yourself_handler', 10, 6 );PK:\_p default-fields/headings/name.phpnuW+A'.$item_title.''.$item_description.''; return apply_filters( 'wppb_'.$form_location.'_default_heading_name_'.$field['id'], $ret_custom_field, $form_location, $field, $user_id, $field_check_errors, $request_data ); } } add_filter( 'wppb_output_form_field_default-name-heading', 'wppb_default_name_handler', 10, 6 );PK:\ (default-fields/first-name/first-name.phpnuW+A*' : '' ); if ( array_key_exists( $field['id'], $field_check_errors ) ) $error_mark = ''; $extra_attr = apply_filters( 'wppb_extra_attribute', '', $field, $form_location ); $output = ' '; if( !empty( $item_description ) ) $output .= ''. $item_description .''; } return apply_filters( 'wppb_'.$form_location.'_firstname', $output, $form_location, $field, $user_id, $field_check_errors, $request_data ); } add_filter( 'wppb_output_form_field_default-first-name', 'wppb_first_name_handler', 10, 6 ); /* handle field validation */ function wppb_check_first_name_value( $message, $field, $request_data, $form_location ){ if( $field['required'] == 'Yes' ){ if( ( isset( $request_data['first_name'] ) && ( trim( $request_data['first_name'] ) == '' ) ) || !isset( $request_data['first_name'] ) ){ return wppb_required_field_error($field["field-title"]); } } return $message; } add_filter( 'wppb_check_form_field_default-first-name', 'wppb_check_first_name_value', 10, 4 ); /* handle field save */ function wppb_userdata_add_first_name( $userdata, $global_request, $form_args ){ if( wppb_field_exists_in_form( 'Default - First Name', $form_args ) ) { if ( isset( $global_request['first_name'] ) ) $userdata['first_name'] = sanitize_text_field( trim( $global_request['first_name'] ) ); } return $userdata; } add_filter( 'wppb_build_userdata', 'wppb_userdata_add_first_name', 10, 3 );PK:\P "default-fields/website/website.phpnuW+A*' : '' ); if ( array_key_exists( $field['id'], $field_check_errors ) ) $error_mark = ''; $extra_attr = apply_filters( 'wppb_extra_attribute', '', $field, $form_location ); $output = ' '; if( !empty( $item_description ) ) $output .= ''. $item_description .''; } return apply_filters( 'wppb_'.$form_location.'_website', $output, $form_location, $field, $user_id, $field_check_errors, $request_data ); } add_filter( 'wppb_output_form_field_default-website', 'wppb_website_handler', 10, 6 ); /* handle field validation */ function wppb_check_website_value( $message, $field, $request_data, $form_location ){ if( $field['required'] == 'Yes' ){ if( ( isset( $request_data['website'] ) && ( trim( $request_data['website'] ) == '' ) ) || !isset( $request_data['website'] ) ){ return wppb_required_field_error($field["field-title"]); } } return $message; } add_filter( 'wppb_check_form_field_default-website', 'wppb_check_website_value', 10, 4 ); /* handle field save */ function wppb_userdata_add_website( $userdata, $global_request, $form_args ){ if( wppb_field_exists_in_form( 'Default - Website', $form_args ) ) { if (isset($global_request['website'])) $userdata['user_url'] = esc_url_raw(trim($global_request['website'])); } return $userdata; } add_filter( 'wppb_build_userdata', 'wppb_userdata_add_website', 10, 3 );PK:\s q default-fields/yim/yim.phpnuW+A*' : '' ); if ( array_key_exists( $field['id'], $field_check_errors ) ) $error_mark = ''; $extra_attr = apply_filters( 'wppb_extra_attribute', '', $field, $form_location ); $output = ' '; if( !empty( $item_description ) ) $output .= ''. $item_description .''; } return apply_filters( 'wppb_'.$form_location.'_yim', $output, $form_location, $field, $user_id, $field_check_errors, $request_data ); } add_filter( 'wppb_output_form_field_default-yahoo-im', 'wppb_yim_handler', 10, 6 ); /* handle field validation */ function wppb_check_yim_value( $message, $field, $request_data, $form_location ){ if( $field['required'] == 'Yes' ){ if( ( isset( $request_data['yim'] ) && ( trim( $request_data['yim'] ) == '' ) ) || !isset( $request_data['yim'] ) ){ return wppb_required_field_error($field["field-title"]); } } return $message; } add_filter( 'wppb_check_form_field_default-yahoo-im', 'wppb_check_yim_value', 10, 4 ); /* handle field save */ function wppb_userdata_add_yim( $userdata, $global_request ){ if ( isset( $global_request['yim'] ) ) $userdata['yim'] = sanitize_text_field( trim( $global_request['yim'] ) ); return $userdata; } add_filter( 'wppb_build_userdata', 'wppb_userdata_add_yim', 10, 2 );PK:\Ƈ~/~/,default-fields/blog-details/blog-details.phpnuW+A'; $item_description = wppb_icl_t( 'plugin profile-builder-pro', 'default_field_'.$field['id'].'_description_translation', $field['description'] ); $heading = '
  • '.wppb_icl_t('plugin profile-builder-pro', 'custom_field_'.$field['id'].'_title_translation', $field['field-title']).'

    '.$item_description.'
  • '; $output .= apply_filters( 'wppb_blog_details_heading', $heading ); ?> .wppb-blog-details-fields {display:none;} '; } $create_new_site_checkbox = '
  • '; $output .= apply_filters( 'wppb_blog_details_checkbox', $create_new_site_checkbox ); $output .= ''; $output .= ''; return apply_filters( 'wppb_blog_details_output', $output, $form_location, $field, $user_id, $field_check_errors, $request_data ); } add_filter( 'wppb_output_form_field_default-blog-details', 'wppb_blog_details_handler', 10, 6 ); /* handle field save */ function wppb_create_blog_on_registration( $field, $user_id, $request_data, $form_location ){ if( $form_location == 'register' && $field['field'] == 'Default - Blog Details' && isset( $request_data['wppb_create_new_site_checkbox'] ) && $request_data['wppb_create_new_site_checkbox'] == 'yes' ) { $blog_url = $request_data['wppb_blog_url']; $blog_title = $request_data['wppb_blog_title']; $usermeta['public'] = ( isset( $request_data['wppb_blog_privacy'] ) && 'Yes' == $request_data['wppb_blog_privacy'] ) ? true : false; $blog_details = wpmu_validate_blog_signup( $blog_url, $blog_title ); if ( empty($blog_details['errors']->errors['blogname']) && empty($blog_details['errors']->errors['blog_title'])) { wpmu_create_blog( $blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $user_id, $usermeta ); } } } add_action( 'wppb_save_form_field', 'wppb_create_blog_on_registration', 10, 4 ); /* handle field validation */ function wppb_check_blog_details_values( $message, $field, $request_data, $form_location ){ if ( isset( $request_data['wppb_create_new_site_checkbox'] ) && $request_data['wppb_create_new_site_checkbox'] == 'yes' ){ $blog_fields_array = wppb_blog_details_fields_array(); foreach ( $blog_fields_array as $blog_field ){ if( ( isset( $request_data[$blog_field] ) && ( trim( $request_data[$blog_field] ) == '' ) ) || !isset( $request_data[$blog_field] ) ){ return wppb_required_field_error($blog_field); } } } return $message; } add_filter( 'wppb_check_form_field_default-blog-details', 'wppb_check_blog_details_values', 10, 4 ); /* Add blog details information to wp_signups table (when Email Confirmation is active) */ function wppb_add_blog_details_to_signup_table( $meta, $global_request, $role ){ if ( isset( $global_request['wppb_create_new_site_checkbox'] ) && $global_request['wppb_create_new_site_checkbox'] == 'yes' ) { $blog_details_fields_array = wppb_blog_details_fields_array(); foreach ($blog_details_fields_array as $blog_field) { $meta[$blog_field] = $global_request[$blog_field]; } } return $meta; } add_filter( 'wppb_add_to_user_signup_form_meta', 'wppb_add_blog_details_to_signup_table',10, 3 ); function wppb_blog_details_fields_array(){ return array( 'wppb_blog_title', 'wppb_blog_url', 'wppb_blog_privacy', 'wppb_create_new_site_checkbox' ); } function wppb_check_individual_blog_fields( $field_key, $request_data, $form_location ){ if ( isset( $request_data['wppb_create_new_site_checkbox'] ) && $request_data['wppb_create_new_site_checkbox'] == 'yes' ) { if ( $field_key == 'wppb_blog_privacy' && ( ! isset( $request_data[$field_key] ) || ( isset( $request_data[$field_key] ) && ( trim( $request_data[$field_key] ) == '' ) ) ) ) { return '' . wppb_required_field_error($field_key) . ''; } $wp_error = wpmu_validate_blog_signup($request_data['wppb_blog_url'], $request_data['wppb_blog_title']); if ( $field_key == 'wppb_blog_url' && !empty($wp_error['errors']->errors['blogname'])){ return '' . $wp_error['errors']->errors['blogname'][0] . ''; } if ( $field_key == 'wppb_blog_title' && !empty($wp_error['errors']->errors['blog_title'])){ return '' . $wp_error['errors']->errors['blog_title'][0] . ''; } } return ''; } PK:\7^mR??,default-fields/display-name/display-name.phpnuW+A*' : '' ); if ( array_key_exists( $field['id'], $field_check_errors ) ) $error_mark = ''; /* * Create the options for the display_name drop-down * They are created same as in user-edit.php of the WordPress core */ $user_data = get_userdata( $user_id ); $public_display = array(); $public_display['display_nickname'] = $user_data->nickname; $public_display['display_username'] = $user_data->user_login; if ( !empty($user_data->first_name) ) $public_display['display_firstname'] = $user_data->first_name; if ( !empty($user_data->last_name) ) $public_display['display_lastname'] = $user_data->last_name; if ( !empty($user_data->first_name) && !empty($user_data->last_name) ) { $public_display['display_firstlast'] = $user_data->first_name . ' ' . $user_data->last_name; $public_display['display_lastfirst'] = $user_data->last_name . ' ' . $user_data->first_name; } if ( !in_array( $user_data->display_name, $public_display ) ) // Only add this if it isn't duplicated elsewhere $public_display = array( 'display_displayname' => $user_data->display_name ) + $public_display; $public_display = array_map( 'trim', $public_display ); $public_display = array_unique( $public_display ); $output = ''; $output .= ''; if( !empty( $item_description ) ) $output .= ''. $item_description .''; } return apply_filters( 'wppb_'.$form_location.'_display-name', $output, $form_location, $field, $user_id, $field_check_errors, $request_data ); } add_filter( 'wppb_output_form_field_default-display-name-publicly-as', 'wppb_display_name_handler', 10, 6 ); /* handle field validation */ function wppb_check_display_name_value( $message, $field, $request_data, $form_location ){ if( $form_location != 'register' ){ if ($field['required'] == 'Yes') { if ((isset($request_data['display_name']) && (trim($request_data['display_name']) == '')) || !isset($request_data['display_name'])) { return wppb_required_field_error($field["field-title"]); } } } return $message; } add_filter( 'wppb_check_form_field_default-display-name-publicly-as', 'wppb_check_display_name_value', 10, 4 ); /* handle field save */ function wppb_userdata_add_display_name( $userdata, $global_request, $form_args ){ if( wppb_field_exists_in_form( 'Default - Display name publicly as', $form_args ) ) { if (isset($global_request['display_name'])) $userdata['display_name'] = trim(sanitize_text_field($global_request['display_name'])); } return $userdata; } add_filter( 'wppb_build_userdata', 'wppb_userdata_add_display_name', 10, 3 );PK:\ݩ%%default-fields/gdpr/gdpr.phpnuW+A*' : '' ); if ( array_key_exists( $field['id'], $field_check_errors ) ) $error_mark = ''; $extra_attr = apply_filters( 'wppb_extra_attribute', '', $field, $form_location ); $output = '