user()->profile['reset_pass_hash_token'] = current_time( 'timestamp' ); UM()->user()->update_usermeta_info('reset_pass_hash_token'); $this->change_password = true; um_reset_user(); } } /** * reset url * * @return bool|string */ function reset_url(){ if ( !um_user('reset_pass_hash') ) return false; $user_id = um_user('ID'); delete_option( "um_cache_userdata_{$user_id}" ); $url = add_query_arg( 'act', 'reset_password', um_get_core_page('password-reset') ); $url = add_query_arg( 'hash', esc_attr( um_user('reset_pass_hash') ), $url ); $url = add_query_arg( 'user_id', esc_attr( um_user('ID') ), $url ); return $url; } /** * we are on password reset page */ function password_reset(){ if ( um_is_core_page('password-reset') ) { UM()->fields()->set_mode = 'password'; } } /** * Password page form */ function form_init() { if ( um_requesting_password_reset() ) { UM()->form()->post_form = $_POST; /** * UM hook * * @type action * @title um_reset_password_errors_hook * @description Action on reset password submit form * @input_vars * [{"var":"$post","type":"array","desc":"Form submitted"}] * @change_log * ["Since: 2.0"] * @usage add_action( 'um_reset_password_errors_hook', 'function_name', 10, 1 ); * @example * */ do_action( 'um_reset_password_errors_hook', UM()->form()->post_form ); if ( ! isset( UM()->form()->errors ) ) { /** * UM hook * * @type action * @title um_reset_password_process_hook * @description Action on reset password success submit form * @input_vars * [{"var":"$post","type":"array","desc":"Form submitted"}] * @change_log * ["Since: 2.0"] * @usage add_action( 'um_reset_password_process_hook', 'function_name', 10, 1 ); * @example * */ do_action( 'um_reset_password_process_hook', UM()->form()->post_form ); } } if ( um_requesting_password_change() ) { UM()->form()->post_form = $_POST; /** * UM hook * * @type action * @title um_change_password_errors_hook * @description Action on change password submit form * @input_vars * [{"var":"$post","type":"array","desc":"Form submitted"}] * @change_log * ["Since: 2.0"] * @usage add_action( 'um_change_password_errors_hook', 'function_name', 10, 1 ); * @example * */ do_action( 'um_change_password_errors_hook', UM()->form()->post_form ); if ( ! isset( UM()->form()->errors ) ) { /** * UM hook * * @type action * @title um_change_password_process_hook * @description Action on change password success submit form * @input_vars * [{"var":"$post","type":"array","desc":"Form submitted"}] * @change_log * ["Since: 2.0"] * @usage add_action( 'um_change_password_process_hook', 'function_name', 10, 1 ); * @example * */ do_action( 'um_change_password_process_hook', UM()->form()->post_form ); } } } /** * Add class based on shortcode * * @param $mode * * @return mixed|string|void */ function get_class( $mode ) { $classes = 'um-'.$mode; if ( is_admin() ) { $classes .= ' um-in-admin'; } if ( UM()->fields()->editing == true ) { $classes .= ' um-editing'; } if ( UM()->fields()->viewing == true ) { $classes .= ' um-viewing'; } /** * UM hook * * @type filter * @title um_form_official_classes__hook * @description Change form additional classes * @input_vars * [{"var":"$classes","type":"string","desc":"Form additional classes"}] * @change_log * ["Since: 2.0"] * @usage * * @example * */ $classes = apply_filters( 'um_form_official_classes__hook', $classes ); return $classes; } /** * Shortcode * * @param array $args * * @return string */ function ultimatemember_password( $args = array() ) { return $this->load( $args ); } /** * Load a module with global function * * @param $args * * @return string */ function load( $args ) { ob_start(); $defaults = array( 'template' => 'password-reset', 'mode' => 'password', 'form_id' => 'um_password_id', 'max_width' => '450px', 'align' => 'center', ); $args = wp_parse_args( $args, $defaults ); if ( empty( $args['use_custom_settings'] ) ) { $args = array_merge( $args, UM()->shortcodes()->get_css_args( $args ) ); } else { $args = array_merge( UM()->shortcodes()->get_css_args( $args ), $args ); } /** * UM hook * * @type filter * @title um_reset_password_shortcode_args_filter * @description Extend Reset Password Arguments * @input_vars * [{"var":"$args","type":"array","desc":"Shortcode arguments"}] * @change_log * ["Since: 2.0"] * @usage * * @example * */ $args = apply_filters( 'um_reset_password_shortcode_args_filter', $args ); if ( isset( $this->change_password ) ) { $args['user_id'] = $_REQUEST['user_id']; $args['template'] = 'password-change'; } extract( $args, EXTR_SKIP ); /** * UM hook * * @type action * @title um_pre_{$mode}_shortcode * @description Action pre-load password form shortcode * @input_vars * [{"var":"$args","type":"array","desc":"Form shortcode pre-loading"}] * @change_log * ["Since: 2.0"] * @usage add_action( 'um_pre_{$mode}_shortcode', 'function_name', 10, 1 ); * @example * */ do_action( "um_pre_{$mode}_shortcode", $args ); /** * UM hook * * @type action * @title um_before_form_is_loaded * @description Action pre-load password form shortcode * @input_vars * [{"var":"$args","type":"array","desc":"Form shortcode pre-loading"}] * @change_log * ["Since: 2.0"] * @usage add_action( 'um_before_form_is_loaded', 'function_name', 10, 1 ); * @example * */ do_action( "um_before_form_is_loaded", $args ); /** * UM hook * * @type action * @title um_before_{$mode}_form_is_loaded * @description Action pre-load password form shortcode * @input_vars * [{"var":"$args","type":"array","desc":"Form shortcode pre-loading"}] * @change_log * ["Since: 2.0"] * @usage add_action( 'um_before_{$mode}_form_is_loaded', 'function_name', 10, 1 ); * @example * */ do_action( "um_before_{$mode}_form_is_loaded", $args ); UM()->shortcodes()->template_load( $template, $args ); if ( ! is_admin() && ! defined( 'DOING_AJAX' ) ) { UM()->shortcodes()->dynamic_css( $args ); } $output = ob_get_contents(); ob_end_clean(); return $output; } } }