From e26a6a33ab3518f1d053593a9b3812f722c1a606 Mon Sep 17 00:00:00 2001 From: nikitasinelnikov Date: Fri, 2 Oct 2020 15:48:59 +0300 Subject: [PATCH] - fixed redirect after registration; - removed empty set_roles() function; - added function for checking AMP; --- includes/core/class-roles-capabilities.php | 12 --------- includes/core/um-actions-profile.php | 2 +- includes/core/um-actions-register.php | 2 ++ includes/um-short-functions.php | 30 ++++++++++++++++++++++ ultimate-member.php | 2 +- 5 files changed, 34 insertions(+), 14 deletions(-) diff --git a/includes/core/class-roles-capabilities.php b/includes/core/class-roles-capabilities.php index eabe88f7..60102c26 100644 --- a/includes/core/class-roles-capabilities.php +++ b/includes/core/class-roles-capabilities.php @@ -345,18 +345,6 @@ if ( ! class_exists( 'um\core\Roles_Capabilities' ) ) { } - /** - * Set roles to user (remove all previous roles) - * make user only with $roles roles - * - * @param int $user_id - * @param string|array $roles - */ - function set_roles( $user_id, $roles ) { - - } - - /** * Get user one of UM roles if it has it * diff --git a/includes/core/um-actions-profile.php b/includes/core/um-actions-profile.php index b2e7a3eb..bec1d452 100644 --- a/includes/core/um-actions-profile.php +++ b/includes/core/um-actions-profile.php @@ -564,7 +564,7 @@ add_filter( 'um_before_save_filter_submitted', array( UM()->validation(), 'valid * @param $to_update */ function um_restore_default_roles( $user_id, $args, $to_update ) { - if ( ! empty( $args['submitted']['role'] ) ) { + if ( ! empty( $args['submitted']['role'] ) && ! empty( $to_update['role'] ) ) { $wp_user = new WP_User( $user_id ); $role_keys = array_map( function( $item ) { diff --git a/includes/core/um-actions-register.php b/includes/core/um-actions-register.php index 5e84a9dd..5f9fffab 100644 --- a/includes/core/um-actions-register.php +++ b/includes/core/um-actions-register.php @@ -206,6 +206,8 @@ function um_check_user_status( $user_id, $args ) { exit( wp_safe_redirect( urldecode( $args['redirect_to'] ) ) ); } + um_fetch_user( $user_id ); + if ( um_user( 'auto_approve_act' ) == 'redirect_url' && um_user( 'auto_approve_url' ) !== '' ) { exit( wp_redirect( um_user( 'auto_approve_url' ) ) ); } diff --git a/includes/um-short-functions.php b/includes/um-short-functions.php index 4e4e0311..8d4c4d02 100644 --- a/includes/um-short-functions.php +++ b/includes/um-short-functions.php @@ -2770,4 +2770,34 @@ if ( ! function_exists( 'um_is_profile_owner' ) ) { return ( $user_id == um_profile_id() ); } +} + + +/** + * Check whether the current page is in AMP mode or not. + * We need to check for specific functions, as there is no special AMP header. + * + * @since 2.1.11 + * + * @param bool $check_theme_support Whether theme support should be checked. Defaults to true. + * + * @uses is_amp_endpoint() AMP by Automattic + * @uses is_better_amp() Better AMP + * + * @return bool + */ +function um_is_amp( $check_theme_support = true ) { + + $is_amp = false; + + if ( ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) || + ( function_exists( 'is_better_amp' ) && is_better_amp() ) ) { + $is_amp = true; + } + + if ( $is_amp && $check_theme_support ) { + $is_amp = current_theme_supports( 'amp' ); + } + + return apply_filters( 'um_is_amp', $is_amp ); } \ No newline at end of file diff --git a/ultimate-member.php b/ultimate-member.php index 54d254b6..5540be2e 100644 --- a/ultimate-member.php +++ b/ultimate-member.php @@ -3,7 +3,7 @@ Plugin Name: Ultimate Member Plugin URI: http://ultimatemember.com/ Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress -Version: 2.1.11-rc.2 +Version: 2.1.11-rc.1 Author: Ultimate Member Author URI: http://ultimatemember.com/ Text Domain: ultimate-member