merge anonymous user name overriding.

This commit is contained in:
CBS Information System 2020-12-17 19:52:35 +09:00
parent 3939af3396
commit 8ef58cad2d

View File

@ -504,11 +504,18 @@ function cbsonline_wpforo_edit_topic_data_filter($args)
{ {
if (!is_user_logged_in() && isset($args['name']) && isset($args['email'])) { if (!is_user_logged_in() && isset($args['name']) && isset($args['email'])) {
$args['status'] = 0; $args['status'] = 0;
if ($args['name'] == wpforo_phrase('Anonymous', false)) {
$host = gethostbyaddr($_SERVER['REMOTE_ADDR'] ?? '127.0.0.1');
if (false !== $host) {
// override name to hostname if name is 'Anonymous'
$args['name'] = $host;
}
}
} }
return $args; return $args;
} }
// - accept to delete topics by anonymous user // - allow to delete topics by anonymous user
add_action('wp_ajax_nopriv_wpforo_delete_ajax', 'cbsonline_wpforo_nopriv_delete'); add_action('wp_ajax_nopriv_wpforo_delete_ajax', 'cbsonline_wpforo_nopriv_delete');
function cbsonline_wpforo_nopriv_delete() function cbsonline_wpforo_nopriv_delete()
{ {
@ -545,17 +552,3 @@ function cbsonline_wpforo_nopriv_delete()
echo json_encode($resp); echo json_encode($resp);
exit(); exit();
} }
// - set hostname if annoymous user add topic data
add_filter('wpforo_add_topic_data_filter', 'cbsonline_wpforo_add_topic_data_filter');
function cbsonline_wpforo_add_topic_data_filter($args)
{
if ($args['name'] == wpforo_phrase('Anonymous', false)) {
$host = gethostbyaddr($_SERVER['REMOTE_ADDR'] ?? '127.0.0.1');
if (false !== $host) {
$args['name'] = $host;
}
}
return $args;
}