diff --git a/functions.php b/functions.php index 8772510..460b817 100644 --- a/functions.php +++ b/functions.php @@ -504,11 +504,18 @@ function cbsonline_wpforo_edit_topic_data_filter($args) { if (!is_user_logged_in() && isset($args['name']) && isset($args['email'])) { $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; } -// - 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'); function cbsonline_wpforo_nopriv_delete() { @@ -545,17 +552,3 @@ function cbsonline_wpforo_nopriv_delete() echo json_encode($resp); 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; -}