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 ***/ 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; do_action('um_reset_password_errors_hook', UM()->form()->post_form ); if ( !isset( UM()->form()->errors) ) { do_action('um_reset_password_process_hook', UM()->form()->post_form ); } } if ( um_requesting_password_change() ) { UM()->form()->post_form = $_POST; do_action('um_change_password_errors_hook', UM()->form()->post_form ); if ( !isset( UM()->form()->errors ) ) { do_action('um_change_password_process_hook', UM()->form()->post_form ); } } } /*** *** @Add class based on shortcode ***/ 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'; } $classes = apply_filters('um_form_official_classes__hook', $classes); return $classes; } /*** *** @Shortcode ***/ function ultimatemember_password( $args = array() ) { return $this->load( $args ); } /*** *** @Load a module with global function ***/ 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 ); } $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 ); do_action("um_pre_{$mode}_shortcode", $args); do_action("um_before_form_is_loaded", $args); 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; } } }