diff --git a/includes/admin/core/packages/2.0-beta1.php b/includes/admin/core/packages/2.0-beta1.php index 200f993f..e1fc9d8d 100644 --- a/includes/admin/core/packages/2.0-beta1.php +++ b/includes/admin/core/packages/2.0-beta1.php @@ -1289,6 +1289,7 @@ foreach ( $member_directories as $directory_id ) { /** * Transferring email templates to new logic */ +$templates_in_theme = 0; $emails = UM()->config()->email_notifications; foreach ( $emails as $email_key => $value ) { @@ -1313,11 +1314,19 @@ foreach ( $emails as $email_key => $value ) { $fp = fopen( $theme_template_path, "w" ); $result = fputs( $fp, $setting_value ); fclose( $fp ); + + $templates_in_theme++; } } } } +if ( $templates_in_theme > 0 ) { + UM()->options()->update( 'email_html', true ); +} else { + UM()->options()->update( 'email_html', false ); +} + /** * Transferring menu restriction data diff --git a/includes/core/class-access.php b/includes/core/class-access.php index 3aadeabe..9e37ca3a 100644 --- a/includes/core/class-access.php +++ b/includes/core/class-access.php @@ -5,8 +5,15 @@ namespace um\core; if ( ! defined( 'ABSPATH' ) ) exit; if ( ! class_exists( 'Access' ) ) { + + + /** + * Class Access + * @package um\core + */ class Access { + /** * If true then we use individual restrict content options * for post @@ -44,9 +51,6 @@ if ( ! class_exists( 'Access' ) ) { $this->redirect_handler = false; $this->allow_access = false; - - - //there is posts (Posts/Page/CPT) filtration if site is accessible //there also will be redirects if they need //protect posts types @@ -352,8 +356,8 @@ if ( ! class_exists( 'Access' ) ) { //also skip if we currently at UM Register|Login|Reset Password pages if ( um_is_core_post( $post, 'register' ) || - um_is_core_post( $post, 'password-reset' ) || - um_is_core_post( $post, 'login' ) ) + um_is_core_post( $post, 'password-reset' ) || + um_is_core_post( $post, 'login' ) ) return; /** @@ -466,416 +470,415 @@ if ( ! class_exists( 'Access' ) ) { } - /** - * User can some of the roles array - * Restrict content new logic - * - * @param $user_id - * @param $roles - * @return bool - */ - function user_can( $user_id, $roles ) { + /** + * User can some of the roles array + * Restrict content new logic + * + * @param $user_id + * @param $roles + * @return bool + */ + function user_can( $user_id, $roles ) { + $user_can = false; - $user_can = false; + if ( ! empty( $roles ) ) { + foreach ( $roles as $key => $value ) { + if ( ! empty( $value ) && user_can( $user_id, $key ) ) { + $user_can = true; + } + } + } - if ( ! empty( $roles ) ) { - foreach ( $roles as $key => $value ) { - if ( ! empty( $value ) && user_can( $user_id, $key ) ) { - $user_can = true; - } - } - } - - return $user_can; - } + return $user_can; + } - /** - * Get privacy settings for post - * return false if post is not private - * Restrict content new logic - * - * @param $post - * @return bool|array - */ - function get_post_privacy_settings( $post ) { - //if logged in administrator all pages are visible - if ( current_user_can( 'administrator' ) ) - return false; + /** + * Get privacy settings for post + * return false if post is not private + * Restrict content new logic + * + * @param $post + * @return bool|array + */ + function get_post_privacy_settings( $post ) { + //if logged in administrator all pages are visible + if ( current_user_can( 'administrator' ) ) + return false; - //exlude from privacy UM default pages (except Members list and User(Profile) page) - if ( ! empty( $post->post_type ) && $post->post_type == 'page' ) { - if ( um_is_core_post( $post, 'login' ) || um_is_core_post( $post, 'register' ) || - um_is_core_post( $post, 'account' ) || um_is_core_post( $post, 'logout' ) || - um_is_core_post( $post, 'password-reset' ) ) - return false; - } + //exlude from privacy UM default pages (except Members list and User(Profile) page) + if ( ! empty( $post->post_type ) && $post->post_type == 'page' ) { + if ( um_is_core_post( $post, 'login' ) || um_is_core_post( $post, 'register' ) || + um_is_core_post( $post, 'account' ) || um_is_core_post( $post, 'logout' ) || + um_is_core_post( $post, 'password-reset' ) ) + return false; + } - $restricted_posts = UM()->options()->get( 'restricted_access_post_metabox' ); + $restricted_posts = UM()->options()->get( 'restricted_access_post_metabox' ); - if ( ! empty( $post->post_type ) && ! empty( $restricted_posts[ $post->post_type ] ) ) { - $restriction = get_post_meta( $post->ID, 'um_content_restriction', true ); + if ( ! empty( $post->post_type ) && ! empty( $restricted_posts[ $post->post_type ] ) ) { + $restriction = get_post_meta( $post->ID, 'um_content_restriction', true ); - if ( ! empty( $restriction['_um_custom_access_settings'] ) ) { - if ( ! isset( $restriction['_um_accessible'] ) || '0' == $restriction['_um_accessible'] ) - return false; - else - return $restriction; - } - } + if ( ! empty( $restriction['_um_custom_access_settings'] ) ) { + if ( ! isset( $restriction['_um_accessible'] ) || '0' == $restriction['_um_accessible'] ) + return false; + else + return $restriction; + } + } - //post hasn't privacy settings....check all terms of this post - $restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' ); + //post hasn't privacy settings....check all terms of this post + $restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' ); - //get all taxonomies for current post type - $taxonomies = get_object_taxonomies( $post ); + //get all taxonomies for current post type + $taxonomies = get_object_taxonomies( $post ); - //get all post terms - $terms = array(); - if ( ! empty( $taxonomies ) ) { - foreach ( $taxonomies as $taxonomy ) { - if ( empty( $restricted_taxonomies[$taxonomy] ) ) - continue; + //get all post terms + $terms = array(); + if ( ! empty( $taxonomies ) ) { + foreach ( $taxonomies as $taxonomy ) { + if ( empty( $restricted_taxonomies[$taxonomy] ) ) + continue; - $terms = array_merge( $terms, wp_get_post_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ) ); - } - } + $terms = array_merge( $terms, wp_get_post_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ) ); + } + } - //get restriction options for first term with privacy settigns - foreach ( $terms as $term_id ) { - $restriction = get_term_meta( $term_id, 'um_content_restriction', true ); + //get restriction options for first term with privacy settigns + foreach ( $terms as $term_id ) { + $restriction = get_term_meta( $term_id, 'um_content_restriction', true ); - if ( ! empty( $restriction['_um_custom_access_settings'] ) ) { - if ( ! isset( $restriction['_um_accessible'] ) || '0' == $restriction['_um_accessible'] ) - continue; - else - return $restriction; - } - } + if ( ! empty( $restriction['_um_custom_access_settings'] ) ) { + if ( ! isset( $restriction['_um_accessible'] ) || '0' == $restriction['_um_accessible'] ) + continue; + else + return $restriction; + } + } - //post is public - return false; - } + //post is public + return false; + } - /** - * Protect Post Types in query - * Restrict content new logic - * - * @param $posts - * @param $query - * @return array - */ - function filter_protected_posts( $posts, $query ) { - $filtered_posts = array(); + /** + * Protect Post Types in query + * Restrict content new logic + * + * @param $posts + * @param $query + * @return array + */ + function filter_protected_posts( $posts, $query ) { + $filtered_posts = array(); - //if empty - if ( empty( $posts ) ) - return $posts; + //if empty + if ( empty( $posts ) ) + return $posts; - $restricted_global_message = UM()->options()->get( 'restricted_access_message' ); + $restricted_global_message = UM()->options()->get( 'restricted_access_message' ); - //other filter - foreach ( $posts as $post ) { - $restriction = $this->get_post_privacy_settings( $post ); + //other filter + foreach ( $posts as $post ) { + $restriction = $this->get_post_privacy_settings( $post ); - if ( ! $restriction ) { - $filtered_posts[] = $post; - continue; - } - - //post is private - if ( '0' == $restriction['_um_accessible'] ) { + if ( ! $restriction ) { $filtered_posts[] = $post; continue; - } elseif ( '1' == $restriction['_um_accessible'] ) { - //if post for not logged in users and user is not logged in - if ( ! is_user_logged_in() ) { - $filtered_posts[] = $post; - continue; - } else { + } - if ( current_user_can( 'administrator' ) ) { - $filtered_posts[] = $post; - continue; - } + //post is private + if ( '0' == $restriction['_um_accessible'] ) { + $filtered_posts[] = $post; + continue; + } elseif ( '1' == $restriction['_um_accessible'] ) { + //if post for not logged in users and user is not logged in + if ( ! is_user_logged_in() ) { + $filtered_posts[] = $post; + continue; + } else { - if ( empty( $query->is_singular ) ) { - //if not single query when exclude if set _um_access_hide_from_queries - if ( empty( $restriction['_um_access_hide_from_queries'] ) ) { + if ( current_user_can( 'administrator' ) ) { + $filtered_posts[] = $post; + continue; + } - if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) { + if ( empty( $query->is_singular ) ) { + //if not single query when exclude if set _um_access_hide_from_queries + if ( empty( $restriction['_um_access_hide_from_queries'] ) ) { - if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) { - $post->post_content = stripslashes( $restricted_global_message ); - } elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) { - $post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : ''; - } + if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) { - } + if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) { + $post->post_content = stripslashes( $restricted_global_message ); + } elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) { + $post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : ''; + } - $filtered_posts[] = $post; - continue; - } - } else { - $this->singular_page = true; + } - //if single post query - if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) { + $filtered_posts[] = $post; + continue; + } + } else { + $this->singular_page = true; - if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) { - $post->post_content = stripslashes( $restricted_global_message ); - } elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) { - $post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : ''; - } + //if single post query + if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) { - $this->current_single_post = $post; - add_filter( 'the_content', array( &$this, 'replace_post_content' ), 9999, 1 ); + if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) { + $post->post_content = stripslashes( $restricted_global_message ); + } elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) { + $post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : ''; + } - /** - * UM hook - * - * @type action - * @title um_access_fix_external_post_content - * @description Hook for 3-d party content filtration - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_access_fix_external_post_content', 'function_name', 10 ); - * @example - * - */ - do_action( 'um_access_fix_external_post_content' ); + $this->current_single_post = $post; + add_filter( 'the_content', array( &$this, 'replace_post_content' ), 9999, 1 ); - $filtered_posts[] = $post; - continue; - } elseif ( '1' == $restriction['_um_noaccess_action'] ) { - $curr = UM()->permalinks()->get_current_url(); + /** + * UM hook + * + * @type action + * @title um_access_fix_external_post_content + * @description Hook for 3-d party content filtration + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_access_fix_external_post_content', 'function_name', 10 ); + * @example + * + */ + do_action( 'um_access_fix_external_post_content' ); - if ( ! isset( $restriction['_um_access_redirect'] ) || '0' == $restriction['_um_access_redirect'] ) { + $filtered_posts[] = $post; + continue; + } elseif ( '1' == $restriction['_um_noaccess_action'] ) { + $curr = UM()->permalinks()->get_current_url(); - exit( wp_redirect( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) ) ) ); + if ( ! isset( $restriction['_um_access_redirect'] ) || '0' == $restriction['_um_access_redirect'] ) { - } elseif ( '1' == $restriction['_um_access_redirect'] ) { + exit( wp_redirect( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) ) ) ); - if ( ! empty( $restriction['_um_access_redirect_url'] ) ) { - $redirect = $restriction['_um_access_redirect_url']; - } else { - $redirect = esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) ); - } + } elseif ( '1' == $restriction['_um_access_redirect'] ) { - exit( wp_redirect( $redirect ) ); - } + if ( ! empty( $restriction['_um_access_redirect_url'] ) ) { + $redirect = $restriction['_um_access_redirect_url']; + } else { + $redirect = esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) ); + } - } - } - } - } elseif ( '2' == $restriction['_um_accessible'] ) { - //if post for logged in users and user is not logged in - if ( is_user_logged_in() ) { + exit( wp_redirect( $redirect ) ); + } - if ( current_user_can( 'administrator' ) ) { - $filtered_posts[] = $post; - continue; - } + } + } + } + } elseif ( '2' == $restriction['_um_accessible'] ) { + //if post for logged in users and user is not logged in + if ( is_user_logged_in() ) { - $custom_restrict = $this->um_custom_restriction( $restriction ); + if ( current_user_can( 'administrator' ) ) { + $filtered_posts[] = $post; + continue; + } - if ( empty( $restriction['_um_access_roles'] ) || false === array_search( '1', $restriction['_um_access_roles'] ) ) { - if ( $custom_restrict ) { - $filtered_posts[] = $post; - continue; - } - } else { - $user_can = $this->user_can( get_current_user_id(), $restriction['_um_access_roles'] ); + $custom_restrict = $this->um_custom_restriction( $restriction ); - if ( isset( $user_can ) && $user_can && $custom_restrict ) { - $filtered_posts[] = $post; - continue; - } - } + if ( empty( $restriction['_um_access_roles'] ) || false === array_search( '1', $restriction['_um_access_roles'] ) ) { + if ( $custom_restrict ) { + $filtered_posts[] = $post; + continue; + } + } else { + $user_can = $this->user_can( get_current_user_id(), $restriction['_um_access_roles'] ); - if ( empty( $query->is_singular ) ) { - //if not single query when exclude if set _um_access_hide_from_queries - if ( empty( $restriction['_um_access_hide_from_queries'] ) ) { + if ( isset( $user_can ) && $user_can && $custom_restrict ) { + $filtered_posts[] = $post; + continue; + } + } - if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) { + if ( empty( $query->is_singular ) ) { + //if not single query when exclude if set _um_access_hide_from_queries + if ( empty( $restriction['_um_access_hide_from_queries'] ) ) { - if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) { - $post->post_content = stripslashes( $restricted_global_message ); - } elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) { - $post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : ''; - } + if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) { - } + if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) { + $post->post_content = stripslashes( $restricted_global_message ); + } elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) { + $post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : ''; + } - $filtered_posts[] = $post; - continue; - } - } else { - $this->singular_page = true; + } - //if single post query - if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) { + $filtered_posts[] = $post; + continue; + } + } else { + $this->singular_page = true; - if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) { - $post->post_content = stripslashes( $restricted_global_message ); + //if single post query + if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) { - $this->current_single_post = $post; - add_filter( 'the_content', array( &$this, 'replace_post_content' ), 9999, 1 ); + if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) { + $post->post_content = stripslashes( $restricted_global_message ); - if ( 'attachment' == $post->post_type ) { - remove_filter( 'the_content', 'prepend_attachment' ); - } - } elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) { - $post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : ''; + $this->current_single_post = $post; + add_filter( 'the_content', array( &$this, 'replace_post_content' ), 9999, 1 ); - $this->current_single_post = $post; - add_filter( 'the_content', array( &$this, 'replace_post_content' ), 9999, 1 ); + if ( 'attachment' == $post->post_type ) { + remove_filter( 'the_content', 'prepend_attachment' ); + } + } elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) { + $post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : ''; - if ( 'attachment' == $post->post_type ) { - remove_filter( 'the_content', 'prepend_attachment' ); - } - } + $this->current_single_post = $post; + add_filter( 'the_content', array( &$this, 'replace_post_content' ), 9999, 1 ); - /** - * UM hook - * - * @type action - * @title um_access_fix_external_post_content - * @description Hook for 3-d party content filtration - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_access_fix_external_post_content', 'function_name', 10 ); - * @example - * - */ - do_action( 'um_access_fix_external_post_content' ); + if ( 'attachment' == $post->post_type ) { + remove_filter( 'the_content', 'prepend_attachment' ); + } + } - $filtered_posts[] = $post; - continue; - } elseif ( '1' == $restriction['_um_noaccess_action'] ) { + /** + * UM hook + * + * @type action + * @title um_access_fix_external_post_content + * @description Hook for 3-d party content filtration + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_access_fix_external_post_content', 'function_name', 10 ); + * @example + * + */ + do_action( 'um_access_fix_external_post_content' ); - $curr = UM()->permalinks()->get_current_url(); + $filtered_posts[] = $post; + continue; + } elseif ( '1' == $restriction['_um_noaccess_action'] ) { - if ( ! isset( $restriction['_um_access_redirect'] ) || '0' == $restriction['_um_access_redirect'] ) { + $curr = UM()->permalinks()->get_current_url(); - exit( wp_redirect( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) ) ) ); + if ( ! isset( $restriction['_um_access_redirect'] ) || '0' == $restriction['_um_access_redirect'] ) { - } elseif ( '1' == $restriction['_um_access_redirect'] ) { + exit( wp_redirect( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) ) ) ); - if ( ! empty( $restriction['_um_access_redirect_url'] ) ) { - $redirect = $restriction['_um_access_redirect_url']; - } else { - $redirect = esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) ); - } + } elseif ( '1' == $restriction['_um_access_redirect'] ) { - exit( wp_redirect( $redirect ) ); - } + if ( ! empty( $restriction['_um_access_redirect_url'] ) ) { + $redirect = $restriction['_um_access_redirect_url']; + } else { + $redirect = esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) ); + } - } - } + exit( wp_redirect( $redirect ) ); + } - } else { - if ( empty( $query->is_singular ) ) { - if ( empty( $restriction['_um_access_hide_from_queries'] ) ) { + } + } - if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) { + } else { + if ( empty( $query->is_singular ) ) { + if ( empty( $restriction['_um_access_hide_from_queries'] ) ) { - if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) { - $post->post_content = stripslashes( $restricted_global_message ); - } elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) { - $post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : ''; - } + if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) { - } + if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) { + $post->post_content = stripslashes( $restricted_global_message ); + } elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) { + $post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : ''; + } - $filtered_posts[] = $post; - continue; - } - } else { - $this->singular_page = true; + } - //if single post query - if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) { + $filtered_posts[] = $post; + continue; + } + } else { + $this->singular_page = true; - if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) { - $post->post_content = stripslashes( $restricted_global_message ); + //if single post query + if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) { - $this->current_single_post = $post; - add_filter( 'the_content', array( &$this, 'replace_post_content' ), 9999, 1 ); + if ( ! isset( $restriction['_um_restrict_by_custom_message'] ) || '0' == $restriction['_um_restrict_by_custom_message'] ) { + $post->post_content = stripslashes( $restricted_global_message ); - if ( 'attachment' == $post->post_type ) { - remove_filter( 'the_content', 'prepend_attachment' ); - } - } elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) { - $post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : ''; + $this->current_single_post = $post; + add_filter( 'the_content', array( &$this, 'replace_post_content' ), 9999, 1 ); - $this->current_single_post = $post; - add_filter( 'the_content', array( &$this, 'replace_post_content' ), 9999, 1 ); + if ( 'attachment' == $post->post_type ) { + remove_filter( 'the_content', 'prepend_attachment' ); + } + } elseif ( '1' == $restriction['_um_restrict_by_custom_message'] ) { + $post->post_content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : ''; - if ( 'attachment' == $post->post_type ) { - remove_filter( 'the_content', 'prepend_attachment' ); - } - } + $this->current_single_post = $post; + add_filter( 'the_content', array( &$this, 'replace_post_content' ), 9999, 1 ); - /** - * UM hook - * - * @type action - * @title um_access_fix_external_post_content - * @description Hook for 3-d party content filtration - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_access_fix_external_post_content', 'function_name', 10 ); - * @example - * - */ - do_action( 'um_access_fix_external_post_content' ); + if ( 'attachment' == $post->post_type ) { + remove_filter( 'the_content', 'prepend_attachment' ); + } + } - $filtered_posts[] = $post; - continue; - } elseif ( '1' == $restriction['_um_noaccess_action'] ) { + /** + * UM hook + * + * @type action + * @title um_access_fix_external_post_content + * @description Hook for 3-d party content filtration + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_access_fix_external_post_content', 'function_name', 10 ); + * @example + * + */ + do_action( 'um_access_fix_external_post_content' ); - $curr = UM()->permalinks()->get_current_url(); + $filtered_posts[] = $post; + continue; + } elseif ( '1' == $restriction['_um_noaccess_action'] ) { - if ( ! isset( $restriction['_um_access_redirect'] ) || '0' == $restriction['_um_access_redirect'] ) { + $curr = UM()->permalinks()->get_current_url(); - exit( wp_redirect( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) ) ) ); + if ( ! isset( $restriction['_um_access_redirect'] ) || '0' == $restriction['_um_access_redirect'] ) { - } elseif ( '1' == $restriction['_um_access_redirect'] ) { + exit( wp_redirect( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) ) ) ); - if ( ! empty( $restriction['_um_access_redirect_url'] ) ) { - $redirect = $restriction['_um_access_redirect_url']; - } else { - $redirect = esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) ); - } + } elseif ( '1' == $restriction['_um_access_redirect'] ) { - exit( wp_redirect( $redirect ) ); - } - } - } - } - } - } + if ( ! empty( $restriction['_um_access_redirect_url'] ) ) { + $redirect = $restriction['_um_access_redirect_url']; + } else { + $redirect = esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) ); + } - return $filtered_posts; - } + exit( wp_redirect( $redirect ) ); + } + } + } + } + } + } + + return $filtered_posts; + } /** @@ -885,92 +888,90 @@ if ( ! class_exists( 'Access' ) ) { */ function replace_post_content( $content ) { $content = $this->current_single_post->post_content; - return $content; } - /** - * Protect Post Types in menu query - * Restrict content new logic - * @param $menu_items - * @param $args - * @return array - */ - function filter_menu( $menu_items, $args ) { - //if empty - if ( empty( $menu_items ) ) - return $menu_items; + /** + * Protect Post Types in menu query + * Restrict content new logic + * @param $menu_items + * @param $args + * @return array + */ + function filter_menu( $menu_items, $args ) { + //if empty + if ( empty( $menu_items ) ) + return $menu_items; - $filtered_items = array(); + $filtered_items = array(); - //other filter - foreach ( $menu_items as $menu_item ) { + //other filter + foreach ( $menu_items as $menu_item ) { - if ( ! empty( $menu_item->object_id ) && ! empty( $menu_item->object ) ) { + if ( ! empty( $menu_item->object_id ) && ! empty( $menu_item->object ) ) { - $restriction = $this->get_post_privacy_settings( get_post( $menu_item->object_id ) ); - if ( ! $restriction ) { - $filtered_items[] = $menu_item; - continue; - } + $restriction = $this->get_post_privacy_settings( get_post( $menu_item->object_id ) ); + if ( ! $restriction ) { + $filtered_items[] = $menu_item; + continue; + } - //post is private - if ( '1' == $restriction['_um_accessible'] ) { - //if post for not logged in users and user is not logged in - if ( ! is_user_logged_in() ) { - $filtered_items[] = $menu_item; - continue; - } else { - //if not single query when exclude if set _um_access_hide_from_queries - if ( empty( $restriction['_um_access_hide_from_queries'] ) ) { - $filtered_items[] = $menu_item; - continue; - } - } - } elseif ( '2' == $restriction['_um_accessible'] ) { - //if post for logged in users and user is not logged in - if ( is_user_logged_in() ) { + //post is private + if ( '1' == $restriction['_um_accessible'] ) { + //if post for not logged in users and user is not logged in + if ( ! is_user_logged_in() ) { + $filtered_items[] = $menu_item; + continue; + } else { + //if not single query when exclude if set _um_access_hide_from_queries + if ( empty( $restriction['_um_access_hide_from_queries'] ) ) { + $filtered_items[] = $menu_item; + continue; + } + } + } elseif ( '2' == $restriction['_um_accessible'] ) { + //if post for logged in users and user is not logged in + if ( is_user_logged_in() ) { - $custom_restrict = $this->um_custom_restriction( $restriction ); + $custom_restrict = $this->um_custom_restriction( $restriction ); - if ( empty( $restriction['_um_access_roles'] ) || false === array_search( '1', $restriction['_um_access_roles'] ) ) { - if ( $custom_restrict ) { - $filtered_items[] = $menu_item; - continue; - } - } else { - $user_can = $this->user_can( get_current_user_id(), $restriction['_um_access_roles'] ); + if ( empty( $restriction['_um_access_roles'] ) || false === array_search( '1', $restriction['_um_access_roles'] ) ) { + if ( $custom_restrict ) { + $filtered_items[] = $menu_item; + continue; + } + } else { + $user_can = $this->user_can( get_current_user_id(), $restriction['_um_access_roles'] ); - if ( isset( $user_can ) && $user_can && $custom_restrict ) { - $filtered_items[] = $menu_item; - continue; - } - } + if ( isset( $user_can ) && $user_can && $custom_restrict ) { + $filtered_items[] = $menu_item; + continue; + } + } - //if not single query when exclude if set _um_access_hide_from_queries - if ( empty( $restriction['_um_access_hide_from_queries'] ) ) { - $filtered_items[] = $menu_item; - continue; - } + //if not single query when exclude if set _um_access_hide_from_queries + if ( empty( $restriction['_um_access_hide_from_queries'] ) ) { + $filtered_items[] = $menu_item; + continue; + } - } else { - if ( empty( $restriction['_um_access_hide_from_queries'] ) ) { - $filtered_items[] = $menu_item; - continue; - } - } - } + } else { + if ( empty( $restriction['_um_access_hide_from_queries'] ) ) { + $filtered_items[] = $menu_item; + continue; + } + } + } - continue; - } + continue; + } - //add all other posts - $filtered_items[] = $menu_item; + //add all other posts + $filtered_items[] = $menu_item; + } - } - - return $filtered_items; - } - } + return $filtered_items; + } + } } \ No newline at end of file diff --git a/includes/core/class-account.php b/includes/core/class-account.php index 7812af33..46406ab0 100644 --- a/includes/core/class-account.php +++ b/includes/core/class-account.php @@ -5,803 +5,833 @@ namespace um\core; if ( ! defined( 'ABSPATH' ) ) exit; if ( ! class_exists( 'Account' ) ) { - class Account { - var $tabs; - var $current_tab = 'general'; - var $register_fields = array(); - var $tab_output = array(); + /** + * Class Account + * @package um\core + */ + class Account { - function __construct() { - add_shortcode( 'ultimatemember_account', array( &$this, 'ultimatemember_account' ) ); + /** + * @var + */ + var $tabs; - add_action( 'template_redirect', array( &$this, 'account_page_restrict' ), 10001 ); - add_action( 'template_redirect', array( &$this, 'account_submit' ), 10002 ); + /** + * @var string + */ + var $current_tab = 'general'; - add_filter( 'um_predefined_fields_hook', array( &$this, 'predefined_fields_hook' ), 1 ); - } + /** + * @var array + */ + var $register_fields = array(); - /** - * Init AllTabs for user account - * - * @param $args - */ - function init_tabs( $args ) { - $this->tabs = $this->get_tabs(); - - ksort( $this->tabs ); - - $tabs_structed = array(); - foreach ( $this->tabs as $k => $arr ) { - - foreach ( $arr as $id => $info ) { - - if ( ! empty( $args['tab'] ) && $id != $args['tab'] ) - continue; - - $output = $this->get_tab_fields( $id, $args ); - - if ( ! empty( $output ) ) - $tabs_structed[$id] = $info; - - } - - } - - $this->tabs = $tabs_structed; - } - - - function get_tabs() { - $tabs = array(); - $tabs[100]['general'] = array( - 'icon' => 'um-faicon-user', - 'title' => __( 'Account', 'ultimate-member' ), - 'submit_title' => __( 'Update Account', 'ultimate-member' ), - ); - - $tabs[200]['password'] = array( - 'icon' => 'um-faicon-asterisk', - 'title' => __( 'Change Password', 'ultimate-member' ), - 'submit_title' => __( 'Update Password', 'ultimate-member' ), - ); - - $tabs[300]['privacy'] = array( - 'icon' => 'um-faicon-lock', - 'title' => __( 'Privacy', 'ultimate-member' ), - 'submit_title' => __( 'Update Privacy', 'ultimate-member' ), - ); - - $tabs[400]['notifications'] = array( - 'icon' => 'um-faicon-envelope', - 'title' => __( 'Notifications', 'ultimate-member' ), - 'submit_title' => __( 'Update Notifications', 'ultimate-member' ), - ); - - //if user cannot delete profile hide delete tab - if ( um_user( 'can_delete_profile' ) || um_user( 'can_delete_everyone' ) ) { - - $tabs[99999]['delete'] = array( - 'icon' => 'um-faicon-trash-o', - 'title' => __( 'Delete Account', 'ultimate-member' ), - 'submit_title' => __( 'Delete Account', 'ultimate-member' ), - ); - - } - - /** - * UM hook - * - * @type filter - * @title um_account_page_default_tabs_hook - * @description Account Page Tabs - * @input_vars - * [{"var":"$tabs","type":"array","desc":"Account Page Tabs"}] - * @change_log - * ["Since: 2.0"] - * @usage add_filter( 'um_account_page_default_tabs_hook', 'function_name', 10, 1 ); - * @example - * - */ - return apply_filters( 'um_account_page_default_tabs_hook', $tabs ); - } - - - /** - * Account Shortcode - * - * @param array $args - * @return string - */ - function ultimatemember_account( $args = array() ) { - um_fetch_user( get_current_user_id() ); - - ob_start(); - - $defaults = array( - 'template' => 'account', - 'mode' => 'account', - 'form_id' => 'um_account_id', - ); - $args = wp_parse_args( $args, $defaults ); - - /** - * UM hook - * - * @type filter - * @title um_account_shortcode_args_filter - * @description Account Shortcode Arguments - * @input_vars - * [{"var":"$args","type":"array","desc":"Shortcode Arguments"}] - * @change_log - * ["Since: 2.0"] - * @usage add_filter( 'um_account_shortcode_args_filter', 'function_name', 10, 1 ); - * @example - * - */ - $args = apply_filters( 'um_account_shortcode_args_filter', $args ); - - if ( ! empty( $args['tab'] ) ) { - - if ( $args['tab'] == 'account' ) - $args['tab'] = 'general'; - - $this->init_tabs( $args ); - - $this->current_tab = $args['tab']; - - if ( ! empty( $this->tabs[ $args['tab'] ] ) ) { ?> -
| - - | -
- um_user_public_key ) ) { ?>
- - - -
- um_user_public_key; ?> - - - |
-
|---|
| + + | +
+ um_user_public_key ) ) { ?>
+ + + +
+ um_user_public_key; ?> + + + |
+
|---|
'; + /** + * Get last send time + * + * @return mixed|void + */ + private function get_last_send() { + return get_option( 'um_tracking_last_send' ); + } - printf( __( 'Thanks for installing %s! The core plugin is free but we also sell extensions which allow us to continue developing and supporting the plugin full time. If you subscribe to our mailing list (no spam) we will email you a 20%% discount code which you can use to purchase the extensions bundle.', 'ultimate-member' ), ultimatemember_plugin_name, 'https://ultimatemember.com/core-extensions-bundle/' ); - echo '
'; + /** + * Send a report + * + * @param bool $override + */ + public function send_checkin( $override = false ) { - echo '' . __( 'Subscribe to mailing list', 'ultimate-member' ) . ''; - echo ' ' . __( 'No thanks', 'ultimate-member' ) . '
'; + + printf( __( 'Thanks for installing %s! The core plugin is free but we also sell extensions which allow us to continue developing and supporting the plugin full time. If you subscribe to our mailing list (no spam) we will email you a 20%% discount code which you can use to purchase the extensions bundle.', 'ultimate-member' ), ultimatemember_plugin_name, 'https://ultimatemember.com/core-extensions-bundle/' ); + + echo '
'; + + echo '' . __( 'Subscribe to mailing list', 'ultimate-member' ) . ''; + echo ' ' . __( 'No thanks', 'ultimate-member' ) . '
| - | - - | -
|---|
| + | + + | +
|---|
- - -
- - - - - - - - ++ + +
+ + + + form()->add_error( 'username', __('Please enter your username or email','ultimate-member') ); - } + if ( isset( $args['username'] ) && $args['username'] == '' ) { + UM()->form()->add_error( 'username', __('Please enter your username or email','ultimate-member') ); + } - if ( isset( $args['user_login'] ) && $args['user_login'] == '' ) { - UM()->form()->add_error( 'user_login', __('Please enter your username','ultimate-member') ); - } + if ( isset( $args['user_login'] ) && $args['user_login'] == '' ) { + UM()->form()->add_error( 'user_login', __('Please enter your username','ultimate-member') ); + } - if ( isset( $args['user_email'] ) && $args['user_email'] == '' ) { - UM()->form()->add_error( 'user_email', __('Please enter your email','ultimate-member') ); - } + if ( isset( $args['user_email'] ) && $args['user_email'] == '' ) { + UM()->form()->add_error( 'user_email', __('Please enter your email','ultimate-member') ); + } - if ( isset( $args['username'] ) ) { - $field = 'username'; - if ( is_email( $args['username'] ) ) { - $is_email = true; - $data = get_user_by('email', $args['username'] ); - $user_name = (isset ( $data->user_login ) ) ? $data->user_login : null; - } else { - $user_name = $args['username']; - } - } else if ( isset( $args['user_email'] ) ) { - $field = 'user_email'; - $is_email = true; - $data = get_user_by('email', $args['user_email'] ); - $user_name = (isset ( $data->user_login ) ) ? $data->user_login : null; + if ( isset( $args['username'] ) ) { + $field = 'username'; + if ( is_email( $args['username'] ) ) { + $is_email = true; + $data = get_user_by('email', $args['username'] ); + $user_name = (isset ( $data->user_login ) ) ? $data->user_login : null; } else { - $field = 'user_login'; - $user_name = $args['user_login']; + $user_name = $args['username']; } + } else if ( isset( $args['user_email'] ) ) { + $field = 'user_email'; + $is_email = true; + $data = get_user_by('email', $args['user_email'] ); + $user_name = (isset ( $data->user_login ) ) ? $data->user_login : null; + } else { + $field = 'user_login'; + $user_name = $args['user_login']; + } - if ( !username_exists( $user_name ) ) { - if ( $is_email ) { - UM()->form()->add_error( $field, __(' Sorry, we can\'t find an account with that email address','ultimate-member') ); - } else { - UM()->form()->add_error( $field, __(' Sorry, we can\'t find an account with that username','ultimate-member') ); - } + if ( !username_exists( $user_name ) ) { + if ( $is_email ) { + UM()->form()->add_error( $field, __(' Sorry, we can\'t find an account with that email address','ultimate-member') ); } else { - if ( $args['user_password'] == '' ) { - UM()->form()->add_error( 'user_password', __('Please enter your password','ultimate-member') ); - } + UM()->form()->add_error( $field, __(' Sorry, we can\'t find an account with that username','ultimate-member') ); } - - $user = get_user_by( 'login', $user_name ); - if ( $user && wp_check_password( $args['user_password'], $user->data->user_pass, $user->ID) ) { - UM()->login()->auth_id = username_exists( $user_name ); - } else { - UM()->form()->add_error( 'user_password', __('Password is incorrect. Please try again.','ultimate-member') ); - } - - $user = apply_filters( 'authenticate', null, $user_name, $args['user_password'] ); - - $authenticate_user = apply_filters( 'wp_authenticate_user', $user_name, $args['user_password'] ); - - // @since 4.18 replacement for 'wp_login_failed' action hook - // see WP function wp_authenticate() - $ignore_codes = array('empty_username', 'empty_password'); - - if ( is_wp_error( $user ) && ! in_array( $user->get_error_code(), $ignore_codes ) ) { - - UM()->form()->add_error( $user->get_error_code(), __( $user->get_error_message() ,'ultimate-member') ); - } - - if( is_wp_error( $authenticate_user ) && ! in_array( $authenticate_user->get_error_code(), $ignore_codes ) ){ - - UM()->form()->add_error( $authenticate_user->get_error_code(), __( $authenticate_user->get_error_message() ,'ultimate-member') ); - - } - - // if there is an error notify wp - if( UM()->form()->has_error( $field ) || UM()->form()->has_error( $user_password ) || UM()->form()->count_errors() > 0 ) { - do_action( 'wp_login_failed', $user_name ); + } else { + if ( $args['user_password'] == '' ) { + UM()->form()->add_error( 'user_password', __('Please enter your password','ultimate-member') ); } } - /** - * Display the login errors from other plugins - */ - add_action( 'um_before_login_fields', 'um_display_login_errors' ); - function um_display_login_errors( $args ) { - $error = ''; + $user = get_user_by( 'login', $user_name ); + if ( $user && wp_check_password( $args['user_password'], $user->data->user_pass, $user->ID) ) { + UM()->login()->auth_id = username_exists( $user_name ); + } else { + UM()->form()->add_error( 'user_password', __('Password is incorrect. Please try again.','ultimate-member') ); + } + + $user = apply_filters( 'authenticate', null, $user_name, $args['user_password'] ); + + $authenticate_user = apply_filters( 'wp_authenticate_user', $user_name, $args['user_password'] ); + + // @since 4.18 replacement for 'wp_login_failed' action hook + // see WP function wp_authenticate() + $ignore_codes = array('empty_username', 'empty_password'); + + if ( is_wp_error( $user ) && ! in_array( $user->get_error_code(), $ignore_codes ) ) { + + UM()->form()->add_error( $user->get_error_code(), __( $user->get_error_message() ,'ultimate-member') ); + } + + if( is_wp_error( $authenticate_user ) && ! in_array( $authenticate_user->get_error_code(), $ignore_codes ) ){ + + UM()->form()->add_error( $authenticate_user->get_error_code(), __( $authenticate_user->get_error_message() ,'ultimate-member') ); + + } + + // if there is an error notify wp + if( UM()->form()->has_error( $field ) || UM()->form()->has_error( $user_password ) || UM()->form()->count_errors() > 0 ) { + do_action( 'wp_login_failed', $user_name ); + } +} +add_action( 'um_submit_form_errors_hook_login', 'um_submit_form_errors_hook_login', 10 ); + + +/** + * Display the login errors from other plugins + * + * @param $args + */ +function um_display_login_errors( $args ) { + $error = ''; - if( UM()->form()->count_errors() > 0 ) { - $errors = UM()->form()->errors; - // hook for other plugins to display error - $error_keys = array_keys( $errors ); + if( UM()->form()->count_errors() > 0 ) { + $errors = UM()->form()->errors; + // hook for other plugins to display error + $error_keys = array_keys( $errors ); } if( isset( $args['custom_fields'] ) ){ @@ -116,339 +120,364 @@ if ( ! defined( 'ABSPATH' ) ) exit; } } } +add_action( 'um_before_login_fields', 'um_display_login_errors' ); - /*** - *** @login checks thru the frontend login - ***/ - add_action('um_submit_form_errors_hook_logincheck', 'um_submit_form_errors_hook_logincheck', 9999 ); - function um_submit_form_errors_hook_logincheck($args){ - // Logout if logged in - if ( is_user_logged_in() ) { - wp_logout(); - } - $user_id = ( isset( UM()->login()->auth_id ) ) ? UM()->login()->auth_id : ''; - um_fetch_user( $user_id ); +/** + * Login checks thru the frontend login + * + * @param $args + */ +function um_submit_form_errors_hook_logincheck( $args ) { + // Logout if logged in + if ( is_user_logged_in() ) { + wp_logout(); + } - $status = um_user('account_status'); // account status - switch( $status ) { + $user_id = ( isset( UM()->login()->auth_id ) ) ? UM()->login()->auth_id : ''; + um_fetch_user( $user_id ); - // If user can't login to site... - case 'inactive': - case 'awaiting_admin_review': - case 'awaiting_email_confirmation': - case 'rejected': - um_reset_user(); - exit( wp_redirect( add_query_arg( 'err', esc_attr( $status ), UM()->permalinks()->get_current_url() ) ) ); - break; + $status = um_user('account_status'); // account status + switch( $status ) { - } - - if ( isset( $args['form_id'] ) && $args['form_id'] == UM()->shortcodes()->core_login_form() && UM()->form()->errors && !isset( $_POST[ UM()->honeypot ] ) ) { - exit( wp_redirect( um_get_core_page('login') ) ); - } + // If user can't login to site... + case 'inactive': + case 'awaiting_admin_review': + case 'awaiting_email_confirmation': + case 'rejected': + um_reset_user(); + exit( wp_redirect( add_query_arg( 'err', esc_attr( $status ), UM()->permalinks()->get_current_url() ) ) ); + break; } - /*** - *** @store last login timestamp - ***/ - add_action('um_on_login_before_redirect', 'um_store_lastlogin_timestamp', 10, 1); - function um_store_lastlogin_timestamp( $user_id ) { - update_user_meta( $user_id, '_um_last_login', current_time( 'timestamp' ) ); + if ( isset( $args['form_id'] ) && $args['form_id'] == UM()->shortcodes()->core_login_form() && UM()->form()->errors && !isset( $_POST[ UM()->honeypot ] ) ) { + exit( wp_redirect( um_get_core_page('login') ) ); } - add_action( 'wp_login', 'um_store_lastlogin_timestamp_' ); - function um_store_lastlogin_timestamp_( $login ) { - $user = get_user_by('login',$login); - um_store_lastlogin_timestamp( $user->ID ); +} +add_action( 'um_submit_form_errors_hook_logincheck', 'um_submit_form_errors_hook_logincheck', 9999 ); + + +/** + * Store last login timestamp + * + * @param $user_id + */ +function um_store_lastlogin_timestamp( $user_id ) { + update_user_meta( $user_id, '_um_last_login', current_time( 'timestamp' ) ); +} +add_action( 'um_on_login_before_redirect', 'um_store_lastlogin_timestamp', 10, 1 ); + + +/** + * @param $login + */ +function um_store_lastlogin_timestamp_( $login ) { + $user = get_user_by( 'login', $login ); + um_store_lastlogin_timestamp( $user->ID ); +} +add_action( 'wp_login', 'um_store_lastlogin_timestamp_' ); + + +/** + * Login user process + * + * @param array $args + */ +function um_user_login( $args ) { + extract( $args ); + + $rememberme = ( isset( $args['rememberme'] ) && 1 == $args['rememberme'] && isset( $_REQUEST['rememberme'] ) ) ? 1 : 0; + + if ( ( UM()->options()->get('deny_admin_frontend_login') && ! isset( $_GET['provider'] ) ) && strrpos( um_user('wp_roles' ), 'administrator' ) !== false ) { + wp_die( __('This action has been prevented for security measures.','ultimate-member') ); } + UM()->user()->auto_login( um_user( 'ID' ), $rememberme ); + /** - * Login user process + * UM hook * - * @param array $args + * @type action + * @title um_on_login_before_redirect + * @description Hook that runs after successful login and before user is redirected + * @input_vars + * [{"var":"$user_id","type":"int","desc":"User ID"}] + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_on_login_before_redirect', 'function_name', 10, 1 ); + * @example + * */ - function um_user_login( $args ) { - extract( $args ); + do_action( 'um_on_login_before_redirect', um_user( 'ID' ) ); - $rememberme = ( isset( $args['rememberme'] ) && 1 == $args['rememberme'] && isset( $_REQUEST['rememberme'] ) ) ? 1 : 0; - - if ( ( UM()->options()->get('deny_admin_frontend_login') && ! isset( $_GET['provider'] ) ) && strrpos( um_user('wp_roles' ), 'administrator' ) !== false ) { - wp_die( __('This action has been prevented for security measures.','ultimate-member') ); - } - - UM()->user()->auto_login( um_user( 'ID' ), $rememberme ); - - /** - * UM hook - * - * @type action - * @title um_on_login_before_redirect - * @description Hook that runs after successful login and before user is redirected - * @input_vars - * [{"var":"$user_id","type":"int","desc":"User ID"}] - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_on_login_before_redirect', 'function_name', 10, 1 ); - * @example - * - */ - do_action( 'um_on_login_before_redirect', um_user( 'ID' ) ); - - // Priority redirect - if ( ! empty( $args['redirect_to'] ) ) { - exit( wp_redirect( $args['redirect_to'] ) ); - } - - // Role redirect - $after_login = um_user( 'after_login' ); - if ( empty( $after_login ) ) - exit( wp_redirect( um_user_profile_url() ) ); - - switch( $after_login ) { - - case 'redirect_admin': - exit( wp_redirect( admin_url() ) ); - break; - - case 'redirect_url': - /** - * UM hook - * - * @type filter - * @title um_login_redirect_url - * @description Change redirect URL after successful login - * @input_vars - * [{"var":"$url","type":"string","desc":"Redirect URL"}, - * {"var":"$id","type":"int","desc":"User ID"}] - * @change_log - * ["Since: 2.0"] - * @usage - * - * @example - * - */ - $redirect_url = apply_filters( 'um_login_redirect_url', um_user( 'login_redirect_url' ), um_user( 'ID' ) ); - exit( wp_redirect( $redirect_url ) ); - break; - - case 'refresh': - exit( wp_redirect( UM()->permalinks()->get_current_url() ) ); - break; - - case 'redirect_profile': - default: - exit( wp_redirect( um_user_profile_url() ) ); - break; - - } + // Priority redirect + if ( ! empty( $args['redirect_to'] ) ) { + exit( wp_redirect( $args['redirect_to'] ) ); } - add_action( 'um_user_login', 'um_user_login', 10 ); + // Role redirect + $after_login = um_user( 'after_login' ); + if ( empty( $after_login ) ) + exit( wp_redirect( um_user_profile_url() ) ); - /*** - *** @form processing - ***/ - add_action( 'um_submit_form_login', 'um_submit_form_login', 10 ); - function um_submit_form_login( $args ) { + switch( $after_login ) { - if ( ! isset( UM()->form()->errors ) ) { + case 'redirect_admin': + exit( wp_redirect( admin_url() ) ); + break; + + case 'redirect_url': /** * UM hook * - * @type action - * @title um_user_login - * @description Hook that runs after successful submit login form + * @type filter + * @title um_login_redirect_url + * @description Change redirect URL after successful login * @input_vars - * [{"var":"$args","type":"array","desc":"Form data"}] + * [{"var":"$url","type":"string","desc":"Redirect URL"}, + * {"var":"$id","type":"int","desc":"User ID"}] * @change_log * ["Since: 2.0"] - * @usage add_action( 'um_user_login', 'function_name', 10, 1 ); + * @usage + * * @example * */ - do_action( 'um_user_login', $args ); - } + $redirect_url = apply_filters( 'um_login_redirect_url', um_user( 'login_redirect_url' ), um_user( 'ID' ) ); + exit( wp_redirect( $redirect_url ) ); + break; + case 'refresh': + exit( wp_redirect( UM()->permalinks()->get_current_url() ) ); + break; + + case 'redirect_profile': + default: + exit( wp_redirect( um_user_profile_url() ) ); + break; + + } +} +add_action( 'um_user_login', 'um_user_login', 10 ); + + +/** + * Form processing + * + * @param $args + */ +function um_submit_form_login( $args ) { + + if ( ! isset( UM()->form()->errors ) ) { /** * UM hook * * @type action - * @title um_user_login_extra_hook + * @title um_user_login * @description Hook that runs after successful submit login form * @input_vars * [{"var":"$args","type":"array","desc":"Form data"}] * @change_log * ["Since: 2.0"] - * @usage add_action( 'um_user_login_extra_hook', 'function_name', 10, 1 ); + * @usage add_action( 'um_user_login', 'function_name', 10, 1 ); * @example * */ - do_action( 'um_user_login_extra_hook', $args ); + do_action( 'um_user_login', $args ); } - /*** - *** @Show the submit button - ***/ - add_action('um_after_login_fields', 'um_add_submit_button_to_login', 1000); - function um_add_submit_button_to_login($args){ - // DO NOT add when reviewing user's details - if ( UM()->user()->preview == true && is_admin() ) return; + /** + * UM hook + * + * @type action + * @title um_user_login_extra_hook + * @description Hook that runs after successful submit login form + * @input_vars + * [{"var":"$args","type":"array","desc":"Form data"}] + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_user_login_extra_hook', 'function_name', 10, 1 ); + * @example + * + */ + do_action( 'um_user_login_extra_hook', $args ); +} +add_action( 'um_submit_form_login', 'um_submit_form_login', 10 ); - $primary_btn_word = $args['primary_btn_word']; - /** - * UM hook - * - * @type filter - * @title um_login_form_button_one - * @description Change Login Form Primary button - * @input_vars - * [{"var":"$primary_btn_word","type":"string","desc":"Button text"}, - * {"var":"$args","type":"array","desc":"Login Form arguments"}] - * @change_log - * ["Since: 2.0"] - * @usage - * - * @example - * - */ - $primary_btn_word = apply_filters('um_login_form_button_one', $primary_btn_word, $args ); - $secondary_btn_word = $args['secondary_btn_word']; - /** - * UM hook - * - * @type filter - * @title um_login_form_button_two - * @description Change Login Form Secondary button - * @input_vars - * [{"var":"$secondary_btn_word","type":"string","desc":"Button text"}, - * {"var":"$args","type":"array","desc":"Login Form arguments"}] - * @change_log - * ["Since: 2.0"] - * @usage - * - * @example - * - */ - $secondary_btn_word = apply_filters('um_login_form_button_two', $secondary_btn_word, $args ); +/** + * Show the submit button + * + * @param $args + */ +function um_add_submit_button_to_login( $args ) { + // DO NOT add when reviewing user's details + if ( UM()->user()->preview == true && is_admin() ) return; - $secondary_btn_url = ( isset( $args['secondary_btn_url'] ) && $args['secondary_btn_url'] ) ? $args['secondary_btn_url'] : um_get_core_page('register'); - /** - * UM hook - * - * @type filter - * @title um_login_form_button_two_url - * @description Change Login Form Secondary button URL - * @input_vars - * [{"var":"$secondary_btn_url","type":"string","desc":"Button URL"}, - * {"var":"$args","type":"array","desc":"Login Form arguments"}] - * @change_log - * ["Since: 2.0"] - * @usage - * - * @example - * - */ - $secondary_btn_url = apply_filters('um_login_form_button_two_url', $secondary_btn_url, $args ); + $primary_btn_word = $args['primary_btn_word']; + /** + * UM hook + * + * @type filter + * @title um_login_form_button_one + * @description Change Login Form Primary button + * @input_vars + * [{"var":"$primary_btn_word","type":"string","desc":"Button text"}, + * {"var":"$args","type":"array","desc":"Login Form arguments"}] + * @change_log + * ["Since: 2.0"] + * @usage + * + * @example + * + */ + $primary_btn_word = apply_filters('um_login_form_button_one', $primary_btn_word, $args ); - ?> + $secondary_btn_word = $args['secondary_btn_word']; + /** + * UM hook + * + * @type filter + * @title um_login_form_button_two + * @description Change Login Form Secondary button + * @input_vars + * [{"var":"$secondary_btn_word","type":"string","desc":"Button text"}, + * {"var":"$args","type":"array","desc":"Login Form arguments"}] + * @change_log + * ["Since: 2.0"] + * @usage + * + * @example + * + */ + $secondary_btn_word = apply_filters('um_login_form_button_two', $secondary_btn_word, $args ); -' . $err . '
'; - } - - if ( isset( $success ) && !empty( $success ) ) { - $output .= '' . $success . '
'; - } - - echo $output; - - } \ No newline at end of file + } + + if ( isset( $err ) && !empty( $err ) ) { + $output .= '' . $err . '
'; + } + + if ( isset( $success ) && !empty( $success ) ) { + $output .= '' . $success . '
'; + } + + echo $output; +} +add_action( 'um_before_form', 'um_add_update_notice', 500 ); \ No newline at end of file diff --git a/includes/core/um-actions-password.php b/includes/core/um-actions-password.php index a6c76914..876ca53c 100644 --- a/includes/core/um-actions-password.php +++ b/includes/core/um-actions-password.php @@ -1,340 +1,361 @@ - $val ) { - if( strstr( $key, "username_b") ){ - $user = trim( $val ); - } - } - - if ( username_exists( $user ) ) { - $data = get_user_by( 'login', $user ); - $user_email = $data->user_email; - } else if( email_exists( $user ) ) { - $data = get_user_by( 'email', $user ); - $user_email = $user; + foreach ( $_POST as $key => $val ) { + if( strstr( $key, "username_b") ){ + $user = trim( $val ); } - - UM()->password()->reset_request['user_id'] = $data->ID; - UM()->password()->reset_request['user_email'] = $user_email; - - um_fetch_user( $data->ID ); - - UM()->user()->password_reset(); - - um_reset_user(); - } - /*** - *** @process a change request - ***/ - add_action('um_change_password_process_hook','um_change_password_process_hook'); - function um_change_password_process_hook( $args ) { - extract( $args ); - - wp_set_password( $args['user_password'], $args['user_id'] ); - - delete_user_meta( $args['user_id'], 'reset_pass_hash'); - delete_user_meta( $args['user_id'], 'reset_pass_hash_token'); - delete_user_meta( $args['user_id'], 'password_rst_attempts'); - - /** - * UM hook - * - * @type action - * @title um_after_changing_user_password - * @description Hook that runs after user change their password - * @input_vars - * [{"var":"$user_id","type":"int","desc":"User ID"}] - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_after_changing_user_password', 'function_name', 10, 1 ); - * @example - * - */ - do_action( 'um_after_changing_user_password', $args['user_id'] ); - - - if ( is_user_logged_in() ) { - wp_logout(); - } - - exit( wp_redirect( um_get_core_page('login', 'password_changed') ) ); - + if ( username_exists( $user ) ) { + $data = get_user_by( 'login', $user ); + $user_email = $data->user_email; + } else if( email_exists( $user ) ) { + $data = get_user_by( 'email', $user ); + $user_email = $user; } + UM()->password()->reset_request['user_id'] = $data->ID; + UM()->password()->reset_request['user_email'] = $user_email; + + um_fetch_user( $data->ID ); + + UM()->user()->password_reset(); + + um_reset_user(); + +} +add_action( 'um_reset_password_process_hook', 'um_reset_password_process_hook' ); + + +/** + * Process a change request + * + * @param $args + */ +function um_change_password_process_hook( $args ) { + extract( $args ); + + wp_set_password( $args['user_password'], $args['user_id'] ); + + delete_user_meta( $args['user_id'], 'reset_pass_hash'); + delete_user_meta( $args['user_id'], 'reset_pass_hash_token'); + delete_user_meta( $args['user_id'], 'password_rst_attempts'); + /** - * Overrides password changed notification + * UM hook * + * @type action + * @title um_after_changing_user_password + * @description Hook that runs after user change their password + * @input_vars + * [{"var":"$user_id","type":"int","desc":"User ID"}] + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_after_changing_user_password', 'function_name', 10, 1 ); + * @example + * */ - add_action( 'send_password_change_email','um_send_password_change_email', 10, 1 ); - function um_send_password_change_email( $args ) { + do_action( 'um_after_changing_user_password', $args['user_id'] ); - if ( ! is_array( $args ) ) - return false; - /** - * @var $user_id - */ - extract( $args ); + if ( is_user_logged_in() ) { + wp_logout(); + } - if ( ! isset( $user_id ) ) - return false; + exit( wp_redirect( um_get_core_page('login', 'password_changed') ) ); +} +add_action( 'um_change_password_process_hook','um_change_password_process_hook' ); - um_fetch_user( $user_id ); - UM()->user()->password_changed(); - - um_reset_user(); +/** + * Overrides password changed notification + * + * @param $args + * + * @return bool + */ +function um_send_password_change_email( $args ) { + if ( ! is_array( $args ) ) return false; - } - /*** - *** @This is executed after changing password - ***/ - add_action('um_after_changing_user_password','um_after_changing_user_password'); - function um_after_changing_user_password( $user_id ) { + /** + * @var $user_id + */ + extract( $args ); - } + if ( ! isset( $user_id ) ) + return false; - /*** - *** @Error handler: reset password - ***/ - add_action('um_reset_password_errors_hook','um_reset_password_errors_hook'); - function um_reset_password_errors_hook( $args ) { + um_fetch_user( $user_id ); - if ( $_POST[ UM()->honeypot ] != '' ) - wp_die('Hello, spam bot!','ultimate-member'); + UM()->user()->password_changed(); - $form_timestamp = trim($_POST['timestamp']); - $live_timestamp = current_time( 'timestamp' ); + um_reset_user(); - if ( $form_timestamp == '' && UM()->options()->get( 'enable_timebot' ) == 1 ) - wp_die( __('Hello, spam bot!','ultimate-member') ); + return false; +} +add_action( 'send_password_change_email','um_send_password_change_email', 10, 1 ); - if ( $live_timestamp - $form_timestamp < 3 && UM()->options()->get( 'enable_timebot' ) == 1 ) - wp_die( __('Whoa, slow down! You\'re seeing this message because you tried to submit a form too fast and we think you might be a spam bot. If you are a real human being please wait a few seconds before submitting the form. Thanks!','ultimate-member') ); + +/** + * This is executed after changing password + * + * @param $user_id + */ +function um_after_changing_user_password( $user_id ) { + +} +add_action( 'um_after_changing_user_password', 'um_after_changing_user_password' ); + + +/** + * Error handler: reset password + * + * @param $args + */ +function um_reset_password_errors_hook( $args ) { + + if ( $_POST[ UM()->honeypot ] != '' ) + wp_die('Hello, spam bot!','ultimate-member'); + + $form_timestamp = trim($_POST['timestamp']); + $live_timestamp = current_time( 'timestamp' ); + + if ( $form_timestamp == '' && UM()->options()->get( 'enable_timebot' ) == 1 ) + wp_die( __('Hello, spam bot!','ultimate-member') ); + + if ( $live_timestamp - $form_timestamp < 3 && UM()->options()->get( 'enable_timebot' ) == 1 ) + wp_die( __('Whoa, slow down! You\'re seeing this message because you tried to submit a form too fast and we think you might be a spam bot. If you are a real human being please wait a few seconds before submitting the form. Thanks!','ultimate-member') ); - $user = ""; + $user = ""; - foreach ( $_POST as $key => $val ) { - if( strstr( $key, "username_b") ){ - $user = trim( $val ); - } - } - - if ( empty( $user ) ) { - UM()->form()->add_error('username_b', __('Please provide your username or email','ultimate-member') ); + foreach ( $_POST as $key => $val ) { + if( strstr( $key, "username_b") ){ + $user = trim( $val ); } + } - if ( ( !is_email( $user ) && !username_exists( $user ) ) || ( is_email( $user ) && !email_exists( $user ) ) ) { - UM()->form()->add_error('username_b', __('We can\'t find an account registered with that address or username','ultimate-member') ); + if ( empty( $user ) ) { + UM()->form()->add_error('username_b', __('Please provide your username or email','ultimate-member') ); + } + + if ( ( !is_email( $user ) && !username_exists( $user ) ) || ( is_email( $user ) && !email_exists( $user ) ) ) { + UM()->form()->add_error('username_b', __('We can\'t find an account registered with that address or username','ultimate-member') ); + } else { + + if ( is_email( $user ) ) { + $user_id = email_exists( $user ); } else { + $user_id = username_exists( $user ); + } - if ( is_email( $user ) ) { - $user_id = email_exists( $user ); + $attempts = (int)get_user_meta( $user_id, 'password_rst_attempts', true ); + $is_admin = user_can( intval( $user_id ),'manage_options' ); + + if ( UM()->options()->get( 'enable_reset_password_limit' ) ) { // if reset password limit is set + + if ( UM()->options()->get( 'disable_admin_reset_password_limit' ) && $is_admin ) { + // Triggers this when a user has admin capabilities and when reset password limit is disabled for admins } else { - $user_id = username_exists( $user ); - } - - $attempts = (int)get_user_meta( $user_id, 'password_rst_attempts', true ); - $is_admin = user_can( intval( $user_id ),'manage_options' ); - - if ( UM()->options()->get( 'enable_reset_password_limit' ) ) { // if reset password limit is set - - if ( UM()->options()->get( 'disable_admin_reset_password_limit' ) && $is_admin ) { - // Triggers this when a user has admin capabilities and when reset password limit is disabled for admins + $limit = UM()->options()->get( 'reset_password_limit_number' ); + if ( $attempts >= $limit ) { + UM()->form()->add_error('username_b', __('You have reached the limit for requesting password change for this user already. Contact support if you cannot open the email','ultimate-member') ); } else { - $limit = UM()->options()->get( 'reset_password_limit_number' ); - if ( $attempts >= $limit ) { - UM()->form()->add_error('username_b', __('You have reached the limit for requesting password change for this user already. Contact support if you cannot open the email','ultimate-member') ); - } else { - update_user_meta( $user_id, 'password_rst_attempts', $attempts + 1 ); - } + update_user_meta( $user_id, 'password_rst_attempts', $attempts + 1 ); } - - } - } - - } - - /*** - *** @Error handler: changing password - ***/ - add_action('um_change_password_errors_hook','um_change_password_errors_hook'); - function um_change_password_errors_hook( $args ) { - if ( isset( $_POST[ UM()->honeypot ] ) && $_POST[ UM()->honeypot ] != '' ){ - wp_die('Hello, spam bot!','ultimate-member'); - } - - $form_timestamp = trim($_POST['timestamp']); - $live_timestamp = current_time( 'timestamp' ); - - if ( $form_timestamp == '' && UM()->options()->get( 'enable_timebot' ) == 1 ) - wp_die( __('Hello, spam bot!','ultimate-member') ); - - if ( $live_timestamp - $form_timestamp < 3 && UM()->options()->get( 'enable_timebot' ) == 1 ) { - wp_die( __('Whoa, slow down! You\'re seeing this message because you tried to submit a form too fast and we think you might be a spam bot. If you are a real human being please wait a few seconds before submitting the form. Thanks!','ultimate-member') ); - } - - $reset_pass_hash = ''; - - if( isset( $_REQUEST['act'] ) && $_REQUEST['act'] == 'reset_password' && um_is_core_page('password-reset') ){ - $reset_pass_hash = get_user_meta( $args['user_id'], 'reset_pass_hash', true ); - - } - - if( !is_user_logged_in() && isset( $args ) && ! um_is_core_page('password-reset') || - is_user_logged_in() && isset( $args['user_id'] ) && $args['user_id'] != get_current_user_id() || - !is_user_logged_in() && isset( $_REQUEST['hash'] ) && $reset_pass_hash != $_REQUEST['hash'] && um_is_core_page('password-reset') - ){ - wp_die( __( 'This is not possible for security reasons.','ultimate-member') ); - } - - if ( isset( $args['user_password'] ) && empty( $args['user_password'] ) ) { - UM()->form()->add_error('user_password', __('You must enter a new password','ultimate-member') ); - } - - if ( UM()->options()->get( 'reset_require_strongpass' ) ) { - - if ( strlen( utf8_decode( $args['user_password'] ) ) < 8 ) { - UM()->form()->add_error('user_password', __('Your password must contain at least 8 characters','ultimate-member') ); - } - - if ( strlen( utf8_decode( $args['user_password'] ) ) > 30 ) { - UM()->form()->add_error('user_password', __('Your password must contain less than 30 characters','ultimate-member') ); - } - - if ( ! UM()->validation()->strong_pass( $args['user_password'] ) ) { - UM()->form()->add_error('user_password', __('Your password must contain at least one lowercase letter, one capital letter and one number','ultimate-member') ); } } + } - if ( isset( $args['confirm_user_password'] ) && empty( $args['confirm_user_password'] ) ) { - UM()->form()->add_error('confirm_user_password', __('You must confirm your new password','ultimate-member') ); +} +add_action( 'um_reset_password_errors_hook', 'um_reset_password_errors_hook' ); + + +/** + * Error handler: changing password + * + * @param $args + */ +function um_change_password_errors_hook( $args ) { + if ( isset( $_POST[ UM()->honeypot ] ) && $_POST[ UM()->honeypot ] != '' ){ + wp_die('Hello, spam bot!','ultimate-member'); + } + + $form_timestamp = trim($_POST['timestamp']); + $live_timestamp = current_time( 'timestamp' ); + + if ( $form_timestamp == '' && UM()->options()->get( 'enable_timebot' ) == 1 ) + wp_die( __('Hello, spam bot!','ultimate-member') ); + + if ( $live_timestamp - $form_timestamp < 3 && UM()->options()->get( 'enable_timebot' ) == 1 ) { + wp_die( __('Whoa, slow down! You\'re seeing this message because you tried to submit a form too fast and we think you might be a spam bot. If you are a real human being please wait a few seconds before submitting the form. Thanks!','ultimate-member') ); + } + + $reset_pass_hash = ''; + + if( isset( $_REQUEST['act'] ) && $_REQUEST['act'] == 'reset_password' && um_is_core_page('password-reset') ){ + $reset_pass_hash = get_user_meta( $args['user_id'], 'reset_pass_hash', true ); + + } + + if( !is_user_logged_in() && isset( $args ) && ! um_is_core_page('password-reset') || + is_user_logged_in() && isset( $args['user_id'] ) && $args['user_id'] != get_current_user_id() || + !is_user_logged_in() && isset( $_REQUEST['hash'] ) && $reset_pass_hash != $_REQUEST['hash'] && um_is_core_page('password-reset') + ){ + wp_die( __( 'This is not possible for security reasons.','ultimate-member') ); + } + + if ( isset( $args['user_password'] ) && empty( $args['user_password'] ) ) { + UM()->form()->add_error('user_password', __('You must enter a new password','ultimate-member') ); + } + + if ( UM()->options()->get( 'reset_require_strongpass' ) ) { + + if ( strlen( utf8_decode( $args['user_password'] ) ) < 8 ) { + UM()->form()->add_error('user_password', __('Your password must contain at least 8 characters','ultimate-member') ); } - if ( isset( $args['user_password'] ) && isset( $args['confirm_user_password'] ) && $args['user_password'] != $args['confirm_user_password'] ) { - UM()->form()->add_error('confirm_user_password', __('Your passwords do not match','ultimate-member') ); + if ( strlen( utf8_decode( $args['user_password'] ) ) > 30 ) { + UM()->form()->add_error('user_password', __('Your password must contain less than 30 characters','ultimate-member') ); + } + + if ( ! UM()->validation()->strong_pass( $args['user_password'] ) ) { + UM()->form()->add_error('user_password', __('Your password must contain at least one lowercase letter, one capital letter and one number','ultimate-member') ); } } - /*** - *** @hidden fields - ***/ - add_action('um_change_password_page_hidden_fields','um_change_password_page_hidden_fields'); - function um_change_password_page_hidden_fields( $args ) { - - ?> - - - - - - form()->add_error('confirm_user_password', __('You must confirm your new password','ultimate-member') ); } - /*** - *** @hidden fields - ***/ - add_action('um_reset_password_page_hidden_fields','um_reset_password_page_hidden_fields'); - function um_reset_password_page_hidden_fields( $args ) { - - ?> - - - - form()->add_error('confirm_user_password', __('Your passwords do not match','ultimate-member') ); } - /*** - *** @form content - ***/ - add_action('um_reset_password_form', 'um_reset_password_form'); - function um_reset_password_form($args) { +} +add_action( 'um_change_password_errors_hook', 'um_change_password_errors_hook' ); - $fields = UM()->builtin()->get_specific_fields('password_reset_text,username_b'); ?> - $data ) { - $output .= UM()->fields()->edit_field( $key, $data ); - } echo $output; ?> +/** + * Hidden fields + * + * @param $args + */ +function um_change_password_page_hidden_fields( $args ) { + ?> - - */ - do_action( 'um_after_password_reset_fields', $args ); ?> + -