function __construct($args) { // 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(); add_action('wp_footer', array(&$this, 'wppb_print_script')); //print scripts if (!is_multisite() && current_user_can('edit_users') || is_multisite() && current_user_can('manage_network')) { add_action('wppb_before_edit_profile_fields', array(&$this, 'wppb_edit_profile_select_user_to_edit')); } }
function wppb_autologin_after_password_changed() { if (isset($_POST['action']) && $_POST['action'] == 'edit_profile') { if (isset($_POST['passw1']) && !empty($_POST['passw1']) && !empty($_POST['form_name'])) { /* all the error checking filters are defined in each field file so we need them here */ 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'; } /* we get the form_name through $_POST so we can apply correctly the filter so we generate the correct fields in the current form */ $form_fields = apply_filters('wppb_change_form_fields', get_option('wppb_manage_fields'), array('form_type' => 'edit_profile', 'form_fields' => array(), 'form_name' => $_POST['form_name'], 'role' => '', 'ID' => Profile_Builder_Form_Creator::wppb_get_form_id_from_form_name($_POST['form_name'], 'edit_profile'))); if (!empty($form_fields)) { /* check for errors in the form through the filters */ $output_field_errors = array(); foreach ($form_fields as $field) { $error_for_field = apply_filters('wppb_check_form_field_' . Wordpress_Creation_Kit_PB::wck_generate_slug($field['field']), '', $field, $_POST, 'edit_profile'); if (!empty($error_for_field)) { $output_field_errors[$field['id']] = '<span class="wppb-form-error">' . $error_for_field . '</span>'; } } /* if we have no errors change the password */ if (empty($output_field_errors)) { $user_id = get_current_user_id(); if (!is_multisite() && current_user_can('edit_users') || is_multisite() && current_user_can('manage_network')) { if (isset($_GET['edit_user']) && !empty($_GET['edit_user'])) { $user_id = $_GET['edit_user']; } } if (!isset($_GET['edit_user'])) { wp_clear_auth_cookie(); /* set the new password for the user */ wp_set_password($_POST['passw1'], $user_id); // Here we calculate the expiration length of the current auth cookie and compare it to the default expiration. // If it's greater than this, then we know the user checked 'Remember Me' when they logged in. $logged_in_cookie = wp_parse_auth_cookie('', 'logged_in'); /** This filter is documented in wp-includes/pluggable.php */ $default_cookie_life = apply_filters('auth_cookie_expiration', 2 * DAY_IN_SECONDS, $user_id, false); $remember = $logged_in_cookie['expiration'] - time() > $default_cookie_life; wp_set_auth_cookie($user_id, $remember); } else { wp_set_password($_POST['passw1'], $user_id); } } } } } }