138 lines
3.1 KiB
PHP
138 lines
3.1 KiB
PHP
<?php
|
|
namespace XTXPATCH;
|
|
|
|
/*
|
|
* it means someone outside wp is accessing the file, in this case kill it.
|
|
*/
|
|
if (!defined('ABSPATH')) {
|
|
die('You can not access this file!');
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
* creates the plugin menu
|
|
*
|
|
*/
|
|
function add_plugin_menu() {
|
|
\Plgntls_xtx::add_menu(__NAMESPACE__.'\menu_content');
|
|
}
|
|
add_action('admin_menu', __NAMESPACE__.'\add_plugin_menu');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
* the construction of the admin menu page
|
|
*
|
|
*/
|
|
function menu_content() {
|
|
$option_register_email = Xtxpatch::OPTION_REGISTER_EMAIL;
|
|
|
|
$option_register_email_name = $option_register_email['_name'];
|
|
$option_register_email_value = \Plgntls_xtx::get_option_safe($option_register_email);
|
|
|
|
ob_start();
|
|
include(\Plgntls_xtx::root_path() . 'html/admin_menu.html');
|
|
echo ob_get_clean();
|
|
}
|
|
|
|
|
|
|
|
|
|
function define_register_email($request, $option_name, $option_value, $option_default) {
|
|
/*
|
|
* email
|
|
*
|
|
*/
|
|
$email = '';
|
|
if (isset($request['email'])) {
|
|
$email = $request['email'];
|
|
}
|
|
|
|
/*
|
|
* is email ?
|
|
*
|
|
*/
|
|
$is_email_prof = false;
|
|
if (isset($request['is_email_prof']) && $request['is_email_prof'] === 'on') {
|
|
$is_email_prof = true;
|
|
}
|
|
$is_email_partner = false;
|
|
if (isset($request['is_email_partner']) && $request['is_email_partner'] === 'on') {
|
|
$is_email_partner = true;
|
|
}
|
|
|
|
|
|
/*
|
|
* update the option with new values
|
|
*
|
|
*/
|
|
$option_data = array(
|
|
'email' => $email,
|
|
'is_email_prof' => $is_email_prof,
|
|
'is_email_partner' => $is_email_partner,
|
|
);
|
|
\Plgntls_xtx::update_option_safe($option_name, $option_data);
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
* use this filter to check if the role should allow registration email
|
|
* ../../../wordpress_docker/volumes/wp_volume/wp-includes/pluggable.php
|
|
* 2210 : $send_notification_to_user = apply_filters( 'wp_send_new_user_notification_to_user', true, $user );
|
|
*
|
|
*/
|
|
function send_registration_email($send, $user) {
|
|
$role_partner = Xtxpatch::ROLE_PARTNER;
|
|
$role_prof = Xtxpatch::ROLE_PROF;
|
|
$option_register_email = Xtxpatch::OPTION_REGISTER_EMAIL;
|
|
|
|
$email_option = \Plgntls_xtx::get_option_safe($option_register_email['_name']);
|
|
|
|
if (user_can($user, $role_prof)) {
|
|
$send = $email_option['is_email_prof'];
|
|
}
|
|
else if (user_can($user, $role_partner)) {
|
|
$send = $email_option['is_email_partner'];
|
|
}
|
|
|
|
return $send;
|
|
}
|
|
add_filter( 'wp_send_new_user_notification_to_user', __NAMESPACE__.'\send_registration_email', 10, 2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
* use this filter to modify the message of the notification email
|
|
* you can use the specials custer expansions as $$<field>$$
|
|
* ../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/easy-login-woocommerce/includes/class-xoo-el-form-handler.php
|
|
* 24 : add_filter( 'wp_new_user_notification_email', array( __CLASS__, 'newuser_notification_email' ), 20, 3 );
|
|
*
|
|
*/
|
|
function filter_regitration_email($wp_new_user_notification_email, $user, $blogname) {
|
|
$option_register_email = Xtxpatch::OPTION_REGISTER_EMAIL;
|
|
|
|
$email_option = \Plgntls_xtx::get_option_safe($option_register_email['_name']);
|
|
$wp_new_user_notification_email['message'] = $email_option['email'];
|
|
return $wp_new_user_notification_email;
|
|
}
|
|
add_filter('wp_new_user_notification_email', __NAMESPACE__.'\filter_regitration_email', 21, 3);
|
|
|
|
|
|
|
|
|
|
|
|
?>
|