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

This commit is contained in:
nikitozzzzzzz
2018-05-31 11:36:30 +03:00
39 changed files with 1236 additions and 266 deletions
+62 -1
View File
@@ -65,6 +65,10 @@ if ( ! class_exists( 'um\core\Access' ) ) {
add_action( 'template_redirect', array( &$this, 'template_redirect' ), 1000 );
add_action( 'um_access_check_individual_term_settings', array( &$this, 'um_access_check_individual_term_settings' ) );
add_action( 'um_access_check_global_settings', array( &$this, 'um_access_check_global_settings' ) );
/* Disable comments if user has not permission to access current post */
add_filter( 'comments_open', array( $this, 'disable_comments_open' ), 99, 2 );
add_filter( 'get_comments_number', array( $this, 'disable_comments_open' ), 99, 2 );
}
@@ -532,7 +536,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
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' ) )
um_is_core_post( $post, 'password-reset' ) || ( is_user_logged_in() && um_is_core_post( $post, 'user' ) ) )
return false;
}
@@ -934,6 +938,63 @@ if ( ! class_exists( 'um\core\Access' ) ) {
}
/**
* Disable comments if user has not permission to access this post
* @param mixed $open
* @param int $post_id
* @return boolean
*/
public function disable_comments_open( $open, $post_id ) {
static $cache = array();
if ( isset( $cache[ $post_id ] ) ) {
return $cache[ $post_id ] ? $open : false;
}
$post = get_post( $post_id );
$restriction = $this->get_post_privacy_settings( $post );
if ( ! $restriction ) {
$cache[ $post_id ] = $open;
return $open;
}
if ( '1' == $restriction['_um_accessible'] ) {
if ( is_user_logged_in() ) {
if ( ! current_user_can( 'administrator' ) ) {
$open = false;
}
}
} elseif ( '2' == $restriction['_um_accessible'] ) {
if ( ! is_user_logged_in() ) {
$open = false;
} else {
if ( ! current_user_can( 'administrator' ) ) {
$custom_restrict = $this->um_custom_restriction( $restriction );
if ( empty( $restriction['_um_access_roles'] ) || false === array_search( '1', $restriction['_um_access_roles'] ) ) {
if ( ! $custom_restrict ) {
$open = false;
}
} else {
$user_can = $this->user_can( get_current_user_id(), $restriction['_um_access_roles'] );
if ( ! isset( $user_can ) || ! $user_can || ! $custom_restrict ) {
$open = false;
}
}
}
}
}
$cache[ $post_id ] = $open;
return $open;
}
/**
* Protect Post Types in menu query
* Restrict content new logic
+2 -3
View File
@@ -55,6 +55,7 @@ if ( ! class_exists( 'um\core\Account' ) ) {
* @param $args
*/
function init_tabs( $args ) {
$this->tabs = $this->get_tabs();
ksort( $this->tabs );
@@ -75,7 +76,6 @@ if ( ! class_exists( 'um\core\Account' ) ) {
}
}
$this->tabs = $tabs_structed;
}
@@ -527,7 +527,7 @@ if ( ! class_exists( 'um\core\Account' ) ) {
* ?>
*/
$args = apply_filters( 'um_account_tab_privacy_fields', $args, $shortcode_args );
$fields = UM()->builtin()->get_specific_fields( $args );
$fields = $this->account_secure_fields( $fields, $id );
$fields = $this->filter_fields_by_attrs( $fields, $shortcode_args );
@@ -535,7 +535,6 @@ if ( ! class_exists( 'um\core\Account' ) ) {
foreach ( $fields as $key => $data ){
$output .= UM()->fields()->edit_field( $key, $data );
}
break;
case 'delete':
+1 -1
View File
@@ -1252,7 +1252,7 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
*/
$fields_without_metakey = apply_filters( 'um_fields_without_metakey', $fields_without_metakey );
if ( !$show_all ) {
if ( ! $show_all ) {
$this->fields_dropdown = array('image','file','password','rating');
$this->fields_dropdown = array_merge( $this->fields_dropdown, $fields_without_metakey );
} else {
+2
View File
@@ -319,6 +319,8 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
wp_register_script('um_functions', um_url . 'assets/js/um-functions' . $this->suffix . '.js', array('jquery', 'jquery-masonry') );
wp_enqueue_script('um_functions');
wp_enqueue_script( 'um-gdpr', um_url . 'assets/js/um-gdpr' . $this->suffix . '.js', array( 'jquery' ), ultimatemember_version, false );
}
+34 -13
View File
@@ -573,7 +573,8 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
} elseif ( um_user( $key ) && $this->editing == true ) {
if ( strstr( $key, 'user_pass' ) ) {
//show empty value for password fields
if ( strstr( $key, 'user_pass' ) || $type == 'password' ) {
return '';
}
@@ -798,6 +799,11 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
return true;
}
$stripslashed = array_map( 'stripslashes', UM()->form()->post_form[ $key ] );
if ( in_array( $value, $stripslashed ) ) {
return true;
}
if ( in_array( html_entity_decode( $value ), UM()->form()->post_form[ $key ] ) ) {
return true;
}
@@ -808,16 +814,21 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$field_value = um_user( $key );
if ($key == 'role') {
if ( $key == 'role' ) {
$role_keys = get_option( 'um_roles' );
if (!empty( $role_keys )) {
if (in_array( $field_value, $role_keys )) {
if ( ! empty( $role_keys ) ) {
if ( in_array( $field_value, $role_keys ) ) {
$field_value = 'um_' . $field_value;
}
}
/*elseif( $this->set_mode == 'register' ){
$data['default'] = UM()->options()->get( 'register_role' );
}
else{
$data['default'] = get_option( 'default_role' );
}*/
}
/**
@@ -930,19 +941,25 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$um_user_value = um_user( $key );
if ($key == 'role') {
if ( $key == 'role' ) {
$um_user_value = strtolower( $um_user_value );
$role_keys = get_option( 'um_roles' );
if (!empty( $role_keys )) {
if (in_array( $um_user_value, $role_keys )) {
if ( ! empty( $role_keys ) ) {
if ( in_array( $um_user_value, $role_keys ) ) {
$um_user_value = 'um_' . $um_user_value;
}
}
/*elseif( $this->set_mode == 'register' ){
$data['default'] = UM()->options()->get( 'register_role' );
}
else{
$data['default'] = get_option( 'default_role' );
}*/
}
if ($um_user_value == $value) {
if ( $um_user_value == $value ) {
return true;
}
@@ -1578,7 +1595,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
if ($visibility == 'view' && $this->set_mode != 'register') return;
if (( $visibility == 'view' && $this->set_mode == 'register' ) ||
if ( ( $visibility == 'view' && $this->set_mode == 'register' ) ||
( isset( $data['editable'] ) && $data['editable'] == 0 && $this->set_mode == 'profile' )
) {
@@ -1619,6 +1636,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
// forbidden in edit mode?
if (isset( $data['edit_forbidden'] )) return;
// required option
if (isset( $data['required_opt'] )) {
$opt = $data['required_opt'];
@@ -2872,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;
}
@@ -3466,9 +3484,12 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
if (isset( $data['in_group'] ) && $data['in_group'] != '' && $rule != 'group') return;
if ($visibility == 'edit') return;
if ( $visibility == 'edit' ) return;
if (in_array( $type, array( 'block', 'shortcode', 'spacing', 'divider', 'group' ) )) {
//invisible on profile page
if ( $type == 'password' ) return;
if ( in_array( $type, array( 'block', 'shortcode', 'spacing', 'divider', 'group' ) ) ) {
} else {
+2 -14
View File
@@ -331,19 +331,6 @@ if ( ! class_exists( 'um\core\Form' ) ) {
wp_die( 'Hello, spam bot!', 'ultimate-member' );
}
if ( ! in_array( $this->form_data['mode'], array( 'login' ) ) ) {
$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 ( !current_user_can('manage_options') && $live_timestamp - $form_timestamp < 6 && 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') );
}
/**
* UM hook
*
@@ -478,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 );
+86
View File
@@ -0,0 +1,86 @@
<?php
namespace um\core;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'um\core\GDPR' ) ) {
/**
* Class Admin_GDPR
* @package um\core
*/
class GDPR {
/**
* Admin_GDPR constructor.
*/
function __construct() {
add_action( 'um_submit_form_register', array( &$this, 'agreement_validation' ), 9 );
add_filter( 'um_before_save_filter_submitted', array( &$this, 'add_agreement_date' ), 10, 1 );
add_filter( 'um_email_registration_data', array( &$this, 'email_registration_data' ), 10, 1 );
add_action( 'um_after_form_fields', array( &$this, 'display_option' ) );
}
/**
* @param $args
*/
function display_option( $args ) {
if ( isset( $args['use_gdpr'] ) && $args['use_gdpr'] == 1 ) {
require um_path . 'templates/gdpr-register.php';
}
}
/**
* @param $args
*/
function agreement_validation( $args ) {
$gdpr_enabled = get_post_meta( $args['form_id'], '_um_register_use_gdpr', true );
if ( $gdpr_enabled && ! isset( $args['submitted']['use_gdpr_agreement'] ) ) {
UM()->form()->add_error( 'use_gdpr_agreement', isset( $args['use_gdpr_error_text'] ) ? $args['use_gdpr_error_text'] : '' );
}
}
/**
* @param $submitted
*
* @return mixed
*/
function add_agreement_date( $submitted ) {
if ( isset( $submitted['use_gdpr_agreement'] ) ) {
$submitted['use_gdpr_agreement'] = time();
}
return $submitted;
}
/**
* @param $submitted
*
* @return mixed
*/
function email_registration_data( $submitted ) {
$timestamp = ! empty( $submitted['timestamp'] ) ? $submitted['timestamp'] : $submitted['use_gdpr_agreement'];
if ( ! empty( $submitted['use_gdpr_agreement'] ) ) {
$submitted['GDPR Applied'] = date( "d M Y H:i", $timestamp );
unset( $submitted['use_gdpr_agreement'] );
}
return $submitted;
}
}
}
+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
*
+7
View File
@@ -118,11 +118,18 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
// disable private tabs
if ( ! is_admin() ) {
if( is_user_logged_in() ) {
$user_id = um_user('ID');
um_fetch_user( get_current_user_id() );
}
foreach ( $tabs as $id => $tab ) {
if ( ! $this->can_view_tab( $id ) ) {
unset( $tabs[$id] );
}
}
if( is_user_logged_in() ) {
um_fetch_user( $user_id );
}
}
return $tabs;
+104 -63
View File
@@ -39,6 +39,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
add_action( 'init', array( &$this, 'set' ), 1 );
$this->preview = false;
$this->send_mail_on_delete = true;
// a list of keys that should never be in wp_usermeta
$this->update_user_keys = array(
@@ -54,6 +55,8 @@ if ( ! class_exists( 'um\core\User' ) ) {
// When the cache should be cleared
add_action('um_delete_user_hook', array(&$this, 'remove_cached_queue') );
add_action('um_delete_user', array( &$this, 'remove_cache' ), 10, 1 );
add_action('um_after_user_status_is_changed_hook', array(&$this, 'remove_cached_queue') );
// When user cache should be cleared
@@ -83,6 +86,73 @@ if ( ! class_exists( 'um\core\User' ) ) {
add_action( 'wpmu_activate_user', array( &$this, 'add_um_role_wpmu_new_user' ), 10, 1 );
add_action( 'init', array( &$this, 'check_membership' ), 10 );
add_action( 'delete_user', array( &$this, 'delete_user_handler' ), 10, 1 );
add_action( 'wpmu_delete_user', array( &$this, 'delete_user_handler' ), 10, 1 );
}
/**
* @param $user_id
*/
function delete_user_handler( $user_id ) {
um_fetch_user( $user_id );
/**
* UM hook
*
* @type action
* @title um_delete_user_hook
* @description On delete user
* @change_log
* ["Since: 2.0"]
* @usage add_action( 'um_delete_user_hook', 'function_name', 10 );
* @example
* <?php
* add_action( 'um_delete_user_hook', 'my_delete_user', 10 );
* function my_delete_user() {
* // your code here
* }
* ?>
*/
do_action( 'um_delete_user_hook' );
/**
* UM hook
*
* @type action
* @title um_delete_user
* @description On delete user
* @input_vars
* [{"var":"$user_id","type":"int","desc":"User ID"}]
* @change_log
* ["Since: 2.0"]
* @usage add_action( 'um_delete_user', 'function_name', 10, 1 );
* @example
* <?php
* add_action( 'um_delete_user', 'my_delete_user', 10, 1 );
* function my_delete_user( $user_id ) {
* // your code here
* }
* ?>
*/
do_action( 'um_delete_user', um_user( 'ID' ) );
// send email notifications
if ( $this->send_mail_on_delete ) {
UM()->mail()->send( um_user( 'user_email' ), 'deletion_email' );
$emails = um_multi_admin_email();
if ( ! empty( $emails ) ) {
foreach ( $emails as $email ) {
UM()->mail()->send( $email, 'notification_deletion', array( 'admin' => true ) );
}
}
}
// remove uploads
UM()->files()->remove_dir( um_user_uploads_dir() );
}
@@ -890,6 +960,20 @@ if ( ! class_exists( 'um\core\User' ) ) {
unset( $submitted['confirm_user_password'] );
}
//remove all password field values from submitted details
$password_fields = array();
foreach ( $submitted as $k => $v ) {
if ( UM()->fields()->get_field_type( $k ) == 'password' ) {
$password_fields[] = $k;
$password_fields[] = 'confirm_' . $k;
}
}
foreach ( $password_fields as $pw_field ) {
unset( $submitted[ $pw_field ] );
}
/**
* UM hook
*
@@ -1274,59 +1358,10 @@ if ( ! class_exists( 'um\core\User' ) ) {
* @param bool $send_mail
*/
function delete( $send_mail = true ) {
/**
* UM hook
*
* @type action
* @title um_delete_user_hook
* @description On delete user
* @change_log
* ["Since: 2.0"]
* @usage add_action( 'um_delete_user_hook', 'function_name', 10 );
* @example
* <?php
* add_action( 'um_delete_user_hook', 'my_delete_user', 10 );
* function my_delete_user() {
* // your code here
* }
* ?>
*/
do_action( 'um_delete_user_hook' );
/**
* UM hook
*
* @type action
* @title um_delete_user
* @description On delete user
* @input_vars
* [{"var":"$user_id","type":"int","desc":"User ID"}]
* @change_log
* ["Since: 2.0"]
* @usage add_action( 'um_delete_user', 'function_name', 10, 1 );
* @example
* <?php
* add_action( 'um_delete_user', 'my_delete_user', 10, 1 );
* function my_delete_user( $user_id ) {
* // your code here
* }
* ?>
*/
do_action( 'um_delete_user', um_user( 'ID' ) );
// send email notifications
if ( $send_mail ) {
UM()->mail()->send( um_user( 'user_email' ), 'deletion_email' );
$this->send_mail_on_delete = $send_mail;
$emails = um_multi_admin_email();
if ( ! empty( $emails ) ) {
foreach ( $emails as $email ) {
UM()->mail()->send( $email, 'notification_deletion', array( 'admin' => true ) );
}
}
}
// remove uploads
UM()->files()->remove_dir( um_user_uploads_dir() );
$this->delete_user_handler( um_user( 'ID' ) );
// remove user
if ( is_multisite() ) {
@@ -1626,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 );
+3 -1
View File
@@ -108,7 +108,9 @@ function um_action_request_process() {
break;
case 'um_delete':
if ( ! UM()->roles()->um_current_user_can( 'delete', $uid ) ) wp_die( __('You do not have permission to delete this user.','ultimate-member') );
if ( ! UM()->roles()->um_current_user_can( 'delete', $uid ) ) {
wp_die( __('You do not have permission to delete this user.','ultimate-member') );
}
um_fetch_user( $uid );
UM()->user()->delete();
exit( wp_redirect( UM()->permalinks()->get_current_url( true ) ) );
+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' ) {
-19
View File
@@ -133,15 +133,6 @@ 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 = "";
foreach ( $_POST as $key => $val ) {
@@ -197,16 +188,6 @@ function um_change_password_errors_hook( $args ) {
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') ){
+33 -18
View File
@@ -218,8 +218,12 @@ function um_user_edit_profile( $args ) {
// loop through fields
if ( ! empty( $fields ) ) {
foreach ( $fields as $key => $array ) {
/*if ( ! um_can_edit_field( $fields[ $key ] ) )
continue;*/
if ( ! um_can_edit_field( $fields[ $key ] ) && isset( $fields[ $key ]['editable'] ) && ! $fields[ $key ]['editable'] )
continue;
@@ -236,10 +240,15 @@ function um_user_edit_profile( $args ) {
} else {
if ( isset( $userinfo[ $key ] ) && $args['submitted'][ $key ] != $userinfo[ $key ] ) {
$to_update[ $key ] = $args['submitted'][ $key ];
} elseif ( $args['submitted'][ $key ] ) {
$to_update[ $key ] = $args['submitted'][ $key ];
if ( $array['type'] == 'password' ) {
$to_update[ $key ] = wp_hash_password( $args['submitted'][ $key ] );
$args['submitted'][ $key ] = sprintf( __( 'Your choosed %s', 'ultimate-member' ), $array['title'] );
} else {
if ( isset( $userinfo[ $key ] ) && $args['submitted'][ $key ] != $userinfo[ $key ] ) {
$to_update[ $key ] = $args['submitted'][ $key ];
} elseif ( $args['submitted'][ $key ] ) {
$to_update[ $key ] = $args['submitted'][ $key ];
}
}
}
@@ -1368,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>
+45 -6
View File
@@ -54,8 +54,9 @@ function um_after_insert_user( $user_id, $args ) {
//clear Users cached queue
UM()->user()->remove_cached_queue();
um_fetch_user( $user_id );
UM()->user()->set_status( um_user( 'status' ) );
if ( ! empty( $args['submitted'] ) ) {
um_fetch_user( $user_id );
UM()->user()->set_registration_details( $args['submitted'] );
}
@@ -103,7 +104,7 @@ function um_after_insert_user( $user_id, $args ) {
*/
do_action( 'um_registration_complete', $user_id, $args );
}
add_action( 'um_user_register', 'um_after_insert_user', 10, 2 );
add_action( 'um_user_register', 'um_after_insert_user', 1, 2 );
/**
@@ -118,7 +119,7 @@ function um_send_registration_notification( $user_id, $args ) {
$emails = um_multi_admin_email();
if ( ! empty( $emails ) ) {
foreach ( $emails as $email ) {
if ( um_user( 'status' ) != 'pending' ) {
if ( um_user( 'account_status' ) != 'pending' ) {
UM()->mail()->send( $email, 'notification_new_user', array( 'admin' => true ) );
} else {
UM()->mail()->send( $email, 'notification_review', array( 'admin' => true ) );
@@ -136,7 +137,7 @@ add_action( 'um_registration_complete', 'um_send_registration_notification', 10,
* @param $args
*/
function um_check_user_status( $user_id, $args ) {
$status = um_user( 'status' );
$status = um_user( 'account_status' );
/**
* UM hook
@@ -368,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
*
@@ -390,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,
@@ -725,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 );
+62 -10
View File
@@ -367,18 +367,70 @@ add_filter( 'um_get_form_fields', 'um_get_form_fields', 99 );
*/
function um_get_custom_field_array( $array, $fields ) {
if ( isset( $array['conditions'] ) ) {
for ( $a = 0; $a < count( $array['conditions'] ); $a++ ) {
if ( isset( $array['conditional_value'] ) || isset( $array['conditional_value' . $a] ) ) {
foreach ( $array['conditions'] as $key => $value ) {
$condition_metakey = $fields[ $value[1] ]['metakey'];
if ( ! empty( $array['conditions'] ) ) {
foreach ( $array['conditions'] as $key => $value ) {
$condition_metakey = $fields[ $value[1] ]['metakey'];
if ( isset( $_POST[ $condition_metakey ] ) ) {
$cond_value = ( $fields[ $value[1] ]['type'] == 'radio' ) ? $_POST[ $condition_metakey ][0] : $_POST[ $condition_metakey ];
list( $visibility, $parent_key, $op, $parent_value ) = $value;
if ( isset( $_POST[ $condition_metakey ] ) ) {
$cond_value = ( $fields[ $value[1] ]['type'] == 'radio' ) ? $_POST[ $condition_metakey ][0] : $_POST[ $condition_metakey ];
if ( isset( $array['conditional_value'] ) && $cond_value !== $array['conditional_value'] ) {
if ( $visibility == 'hide' ) {
if ( $op == 'empty' ) {
if ( empty( $cond_value ) ) {
$array['required'] = 0;
} elseif ( isset( $array['conditional_value'.$a] ) && $cond_value !== $array['conditional_value'.$a] ) {
}
} elseif ( $op == 'not empty' ) {
if ( ! empty( $cond_value ) ) {
$array['required'] = 0;
}
} elseif ( $op == 'equals to' ) {
if ( $cond_value == $parent_value ) {
$array['required'] = 0;
}
} elseif ( $op == 'not equals' ) {
if ( $cond_value != $parent_value ) {
$array['required'] = 0;
}
} elseif ( $op == 'greater than' ) {
if ( $cond_value > $parent_value ) {
$array['required'] = 0;
}
} elseif ( $op == 'less than' ) {
if ( $cond_value < $parent_value ) {
$array['required'] = 0;
}
} elseif ( $op == 'contains' ) {
if ( strstr( $cond_value, $parent_value ) ) {
$array['required'] = 0;
}
}
} elseif ( $visibility == 'show' ) {
if ( $op == 'empty' ) {
if ( ! empty( $cond_value ) ) {
$array['required'] = 0;
}
} elseif ( $op == 'not empty' ) {
if ( empty( $cond_value ) ) {
$array['required'] = 0;
}
} elseif ( $op == 'equals to' ) {
if ( $cond_value != $parent_value ) {
$array['required'] = 0;
}
} elseif ( $op == 'not equals' ) {
if ( $cond_value == $parent_value ) {
$array['required'] = 0;
}
} elseif ( $op == 'greater than' ) {
if ( $cond_value <= $parent_value ) {
$array['required'] = 0;
}
} elseif ( $op == 'less than' ) {
if ( $cond_value >= $parent_value ) {
$array['required'] = 0;
}
} elseif ( $op == 'contains' ) {
if ( ! strstr( $cond_value, $parent_value ) ) {
$array['required'] = 0;
}
}
+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;
+3 -2
View File
@@ -55,7 +55,8 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
// Sanitize
if ( ! empty( $_POST[ $key ][ $menu_item_db_id ] ) ) {
// Do some checks here...
$value = $_POST[ $key ][ $menu_item_db_id ];
$value = is_array( $_POST[ $key ][ $menu_item_db_id ] ) ?
array_keys( $_POST[ $key ][ $menu_item_db_id ] ) : $_POST[ $key ][ $menu_item_db_id ];
} else {
$value = null;
}
@@ -165,7 +166,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
$id_attr = ' id="edit-menu-item-um_nav_roles-{{data.menuItemID}}_' . $k . '" ';
$for_attr = ' for="edit-menu-item-um_nav_roles-{{data.menuItemID}}_' . $k . '" ';
$html .= "<label $for_attr>
<input type='checkbox' {$id_attr} name='menu-item-um_nav_roles[{{data.menuItemID}}][]' value='{$k}' <# if( _.contains( data.restriction_data.um_nav_roles,'{$k}' ) ){ #>checked='checked'<# } #> />
<input type='checkbox' {$id_attr} name='menu-item-um_nav_roles[{{data.menuItemID}}][{$k}]' value='1' <# if( _.contains( data.restriction_data.um_nav_roles,'{$k}' ) ){ #>checked='checked'<# } #> />
<span>{$title}</span>
</label>";
}