mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-13 19:56:27 +09:00
Merge branch 'master' of https://github.com/ultimatemember/ultimatemember into fix/restrict_comments
This commit is contained in:
@@ -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 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -115,7 +115,7 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
|
||||
'icon' => 'um-faicon-comment'
|
||||
)
|
||||
) );
|
||||
|
||||
um_fetch_user(get_current_user_id());
|
||||
// disable private tabs
|
||||
if ( ! is_admin() ) {
|
||||
foreach ( $tabs as $id => $tab ) {
|
||||
|
||||
@@ -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