mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-19 14:43:49 +09:00
Merge branch 'master' of https://github.com/ultimatemember/ultimatemember
This commit is contained in:
@@ -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 );
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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':
|
||||
@@ -752,6 +751,7 @@ 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'] ) { ?>
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -814,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' );
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -936,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;
|
||||
}
|
||||
|
||||
@@ -1625,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'];
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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() );
|
||||
}
|
||||
|
||||
|
||||
@@ -1288,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() ) {
|
||||
|
||||
@@ -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 ) ) );
|
||||
|
||||
Reference in New Issue
Block a user