Merge branch 'master' of https://github.com/ultimatemember/ultimatemember into fix/ms_email_templates

This commit is contained in:
nikitozzzzzzz
2018-05-30 15:15:57 +03:00
22 changed files with 231 additions and 80 deletions
-1
View File
@@ -751,7 +751,6 @@ if ( ! class_exists( 'um\core\Account' ) ) {
* ?>
*/
do_action( "um_after_account_{$tab_id}", $args );
// var_dump($args);
if ( ! isset( $tab_data['show_button'] ) || false !== $tab_data['show_button'] ) { ?>
+1 -1
View File
@@ -2890,7 +2890,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$um_field_checkbox_item_title = $v;
$option_value = $v;
if (!is_numeric( $k ) && in_array( $form_key, array( 'role' ) )) {
if ( ! is_numeric( $k ) && in_array( $form_key, array( 'role', 'role_radio' ) ) ) {
$um_field_checkbox_item_title = $v;
$option_value = $k;
}
+2 -1
View File
@@ -465,8 +465,9 @@ if ( ! class_exists( 'um\core\Form' ) ) {
$global_role = get_option( 'default_role' ); // WP Global settings
$um_global_role = UM()->options()->get( 'register_role' ); // UM Settings Global settings
if ( ! empty( $um_global_role ) )
if ( ! empty( $um_global_role ) ) {
$global_role = $um_global_role; // Form Global settings
}
$mode = $this->form_type( $post_id );
+6 -18
View File
@@ -124,10 +124,14 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
$this->message = $this->prepare_template( $template, $args );
add_filter( 'wp_mail_content_type', array( &$this, 'set_content_type' ) );
if ( UM()->options()->get( 'email_html' ) ) {
$this->headers .= "Content-Type: text/html\r\n";
} else {
$this->headers .= "Content-Type: text/plain\r\n";
}
// Send mail
wp_mail( $email, $this->subject, $this->message, $this->headers, $this->attachments );
remove_filter( 'wp_mail_content_type', array( &$this, 'set_content_type' ) );
}
@@ -481,22 +485,6 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
}
/**
* Set email content type
*
*
* @param $content_type
* @return string
*/
function set_content_type( $content_type ) {
if ( UM()->options()->get( 'email_html' ) ) {
return 'text/html';
} else {
return 'text/plain';
}
}
/**
* Ajax copy template to the theme
*
+18 -12
View File
@@ -1661,23 +1661,29 @@ if ( ! class_exists( 'um\core\User' ) ) {
}
}
// update user
if ( count( $args ) > 1 ) {
global $wp_roles;
$um_roles = get_option( 'um_roles' );
if ( ! empty( $um_roles ) ) {
$role_keys = array_map( function( $item ) {
return 'um_' . $item;
}, get_option( 'um_roles' ) );
} else {
$role_keys = array();
}
//if isset roles argument validate role to properly for security reasons
if ( isset( $args['role'] ) ) {
global $wp_roles;
$um_roles = get_option( 'um_roles' );
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
if ( ! empty( $um_roles ) ) {
$role_keys = array_map( function( $item ) {
return 'um_' . $item;
}, get_option( 'um_roles' ) );
} else {
$role_keys = array();
}
if ( isset( $args['role'] ) && in_array( $args['role'], $exclude_roles ) ) {
unset( $args['role'] );
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
if ( in_array( $args['role'], $exclude_roles ) ) {
unset( $args['role'] );
}
}
wp_update_user( $args );
+6 -5
View File
@@ -314,8 +314,9 @@ function um_submit_form_errors_hook_( $args ) {
foreach ( $array['conditions'] as $condition ) {
list( $visibility, $parent_key, $op, $parent_value ) = $condition;
if ( ! isset( $args[ $parent_key ] ) )
if ( ! isset( $args[ $parent_key ] ) ) {
continue;
}
$cond_value = ( $fields[ $parent_key ]['type'] == 'radio' ) ? $args[ $parent_key ][0] : $args[ $parent_key ];
@@ -337,11 +338,11 @@ function um_submit_form_errors_hook_( $args ) {
continue 2;
}
} elseif ( $op == 'greater than' ) {
if ( $cond_value > $op ) {
if ( $cond_value > $parent_value ) {
continue 2;
}
} elseif ( $op == 'less than' ) {
if ( $cond_value < $op ) {
if ( $cond_value < $parent_value ) {
continue 2;
}
} elseif ( $op == 'contains' ) {
@@ -367,11 +368,11 @@ function um_submit_form_errors_hook_( $args ) {
continue 2;
}
} elseif ( $op == 'greater than' ) {
if ( $cond_value <= $op ) {
if ( $cond_value <= $parent_value ) {
continue 2;
}
} elseif ( $op == 'less than' ) {
if ( $cond_value >= $op ) {
if ( $cond_value >= $parent_value ) {
continue 2;
}
} elseif ( $op == 'contains' ) {
+20 -14
View File
@@ -1377,40 +1377,46 @@ function um_profile_menu( $args ) {
<div class="um-profile-nav-item um-profile-nav-<?php echo $id . ' ' . $profile_nav_class; ?>">
<?php if ( UM()->options()->get( 'profile_menu_icons' ) ) { ?>
<a href="<?php echo $nav_link; ?>" class="um-tip-n uimob500-show uimob340-show uimob800-show"
<a href="<?php echo $nav_link; ?>" class="uimob800-show uimob500-show uimob340-show um-tip-n"
title="<?php echo esc_attr( $tab['name'] ); ?>" original-title="<?php echo esc_attr( $tab['name'] ); ?>">
<i class="<?php echo $tab['icon']; ?>"></i>
<?php if ( isset( $tab['notifier'] ) && $tab['notifier'] > 0 ) { ?>
<span class="um-tab-notifier uimob500-show uimob340-show uimob800-show"><?php echo $tab['notifier']; ?></span>
<span class="um-tab-notifier uimob800-show uimob500-show uimob340-show"><?php echo $tab['notifier']; ?></span>
<?php } ?>
<span class="uimob500-hide uimob340-hide uimob800-hide title"><?php echo $tab['name']; ?></span>
<span class="uimob800-hide uimob500-hide uimob340-hide title"><?php echo $tab['name']; ?></span>
</a>
<a href="<?php echo $nav_link; ?>" class="uimob500-hide uimob340-hide uimob800-hide"
title="<?php echo esc_attr( $tab['name'] ); ?>" original-title="<?php echo esc_attr( $tab['name'] ); ?>">
<a href="<?php echo $nav_link; ?>" class="uimob800-hide uimob500-hide uimob340-hide"
title="<?php echo esc_attr( $tab['name'] ); ?>">
<i class="<?php echo $tab['icon']; ?>"></i>
<?php if ( isset( $tab['notifier'] ) && $tab['notifier'] > 0 ) { ?>
<span class="um-tab-notifier uimob500-show uimob340-show uimob800-show"><?php echo $tab['notifier']; ?></span>
<span class="um-tab-notifier uimob800-show uimob500-show uimob340-show"><?php echo $tab['notifier']; ?></span>
<?php } ?>
<span class="uimob500-hide uimob340-hide uimob800-hide title"><?php echo $tab['name']; ?></span>
<span class="title"><?php echo $tab['name']; ?></span>
</a>
<?php } else { ?>
<a href="<?php echo $nav_link; ?>" title="<?php echo esc_attr( $tab['name'] ); ?>"
original-title="<?php echo esc_attr( $tab['name'] ); ?>">
<a href="<?php echo $nav_link; ?>" class="uimob800-show uimob500-show uimob340-show um-tip-n"
title="<?php echo esc_attr( $tab['name'] ); ?>" original-title="<?php echo esc_attr( $tab['name'] ); ?>">
<i class="<?php echo $tab['icon']; ?>"></i>
<?php if ( isset( $tab['notifier'] ) && $tab['notifier'] > 0 ) { ?>
<span class="um-tab-notifier uimob800-show uimob500-show uimob340-show"><?php echo $tab['notifier']; ?></span>
<?php } ?>
</a>
<a href="<?php echo $nav_link; ?>" class="uimob800-hide uimob500-hide uimob340-hide"
title="<?php echo esc_attr( $tab['name'] ); ?>">
<?php if ( isset( $tab['notifier'] ) && $tab['notifier'] > 0) { ?>
<span class="um-tab-notifier uimob500-show uimob340-show uimob800-show"><?php echo $tab['notifier']; ?></span>
<span class="um-tab-notifier uimob800-show uimob500-show uimob340-show"><?php echo $tab['notifier']; ?></span>
<?php } ?>
<span class="uimob500-hide uimob340-hide uimob800-hide title"><?php echo $tab['name']; ?></span>
<span class="title"><?php echo $tab['name']; ?></span>
</a>
<?php } ?>
</div>
+41 -3
View File
@@ -55,7 +55,7 @@ function um_after_insert_user( $user_id, $args ) {
UM()->user()->remove_cached_queue();
um_fetch_user( $user_id );
UM()->user()->set_status( um_user('status') );
UM()->user()->set_status( um_user( 'status' ) );
if ( ! empty( $args['submitted'] ) ) {
UM()->user()->set_registration_details( $args['submitted'] );
}
@@ -369,6 +369,30 @@ function um_submit_form_register( $args ) {
$args['submitted'] = array_merge( $args['submitted'], $credentials );
$args = array_merge( $args, $credentials );
//get user role from global or form's settings
$user_role = UM()->form()->assigned_role( UM()->form()->form_id );
//get user role from field Role dropdown or radio
if ( isset( $args['role'] ) ) {
global $wp_roles;
$um_roles = get_option( 'um_roles' );
if ( ! empty( $um_roles ) ) {
$role_keys = array_map( function( $item ) {
return 'um_' . $item;
}, get_option( 'um_roles' ) );
} else {
$role_keys = array();
}
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
//if role is properly set it
if ( ! in_array( $args['role'], $exclude_roles ) ) {
$user_role = $args['role'];
}
}
/**
* UM hook
*
@@ -391,7 +415,7 @@ function um_submit_form_register( $args ) {
* }
* ?>
*/
$user_role = apply_filters( 'um_registration_user_role', UM()->form()->assigned_role( UM()->form()->form_id ), $args );
$user_role = apply_filters( 'um_registration_user_role', $user_role, $args );
$userdata = array(
'user_login' => $user_login,
@@ -726,4 +750,18 @@ function um_registration_set_profile_full_name( $user_id, $args ) {
*/
do_action( 'um_update_profile_full_name', $user_id, $args );
}
add_action( 'um_registration_set_extra_data', 'um_registration_set_profile_full_name', 10, 2 );
add_action( 'um_registration_set_extra_data', 'um_registration_set_profile_full_name', 10, 2 );
/**
* Redirect from default registration to UM registration page
*/
function um_form_register_redirect() {
$page_id = UM()->options()->get( UM()->options()->get_core_page_id( 'register' ) );
$register_post = get_post( $page_id );
if ( ! empty( $register_post ) ) {
wp_safe_redirect( get_permalink( $page_id ) );
exit();
}
}
add_action( 'login_form_register', 'um_form_register_redirect', 10 );
+4 -4
View File
@@ -392,11 +392,11 @@ function um_get_custom_field_array( $array, $fields ) {
$array['required'] = 0;
}
} elseif ( $op == 'greater than' ) {
if ( $cond_value > $op ) {
if ( $cond_value > $parent_value ) {
$array['required'] = 0;
}
} elseif ( $op == 'less than' ) {
if ( $cond_value < $op ) {
if ( $cond_value < $parent_value ) {
$array['required'] = 0;
}
} elseif ( $op == 'contains' ) {
@@ -422,11 +422,11 @@ function um_get_custom_field_array( $array, $fields ) {
$array['required'] = 0;
}
} elseif ( $op == 'greater than' ) {
if ( $cond_value <= $op ) {
if ( $cond_value <= $parent_value ) {
$array['required'] = 0;
}
} elseif ( $op == 'less than' ) {
if ( $cond_value >= $op ) {
if ( $cond_value >= $parent_value ) {
$array['required'] = 0;
}
} elseif ( $op == 'contains' ) {
+1 -1
View File
@@ -211,7 +211,7 @@ function um_add_search_to_query( $query_args, $args ){
*/
$query_args = apply_filters( 'um_query_args_filter', $query_args );
if ( count( $query_args['meta_query'] ) == 1 )
if ( isset( $query_args['meta_query'] ) && count( $query_args['meta_query'] ) == 1 )
unset( $query_args['meta_query'] );
return $query_args;
+1 -1
View File
@@ -47,7 +47,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
if ( empty( $_POST['menu-item-db-id'] ) || ! in_array( $menu_item_db_id, $_POST['menu-item-db-id'] ) ) {
return;
}
//var_dump($_POST['menu-item-um_nav_roles']); exit;
foreach ( self::$fields as $_key => $label ) {
$key = sprintf( 'menu-item-%s', $_key );