accept to delete topics by anonymous user.
This commit is contained in:
@ -507,6 +507,44 @@ function cbsonline_wpforo_edit_topic_data_filter($args)
|
||||
|
||||
return $args;
|
||||
}
|
||||
// - accept to delete topics by anonymous user
|
||||
add_action('wp_ajax_nopriv_wpforo_delete_ajax', 'cbsonline_wpforo_nopriv_delete');
|
||||
function cbsonline_wpforo_nopriv_delete()
|
||||
{
|
||||
if (is_user_logged_in()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$resp = [];
|
||||
$return = 0;
|
||||
if ('topic' === $_POST['status']) {
|
||||
if (WPF()->topic->delete(intval($_POST['postid']))) {
|
||||
$forumid = (int) wpfval($_POST, 'forumid');
|
||||
$resp = [
|
||||
'postid' => intval($_POST['postid']),
|
||||
'location' => $forumid ? WPF()->forum->get_forum_url($forumid) : wpforo_home_url(),
|
||||
];
|
||||
$return = 1;
|
||||
}
|
||||
} elseif ('reply' === $_POST['status']) {
|
||||
$root = WPF()->post->get_root($_POST['postid']);
|
||||
if (WPF()->post->delete(intval($_POST['postid']))) {
|
||||
$root_replies_count = WPF()->post->get_root_replies_count($root);
|
||||
$resp = [
|
||||
'postid' => intval($_POST['postid']),
|
||||
'root' => intval($root),
|
||||
'root_count' => intval($root_replies_count),
|
||||
];
|
||||
$return = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$resp['stat'] = $return;
|
||||
$resp['notice'] = WPF()->notice->get_notices();
|
||||
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)
|
||||
|
Reference in New Issue
Block a user