From c324c37e7a613546b3fe761d478e5c9ae2422d67 Mon Sep 17 00:00:00 2001 From: NIU Administrator Date: Mon, 21 Dec 2020 18:39:23 +0900 Subject: [PATCH] allow to edit topics by anonymous users. --- functions.php | 10 ++++++++++ wpforo/layouts/2/post.php | 14 +++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/functions.php b/functions.php index 460b817..bb236ff 100644 --- a/functions.php +++ b/functions.php @@ -515,6 +515,16 @@ function cbsonline_wpforo_edit_topic_data_filter($args) return $args; } +// - allow to edit topics by anonymous user +add_action('wpforo_start_edit_topic', 'cbsonline_wpforo_start_edit_topic'); +function cbsonline_wpforo_start_edit_topic($args) +{ + if (!is_user_logged_in()) { + if ($topic = WPF()->topic->get_topic($args['topicid'])) { + WPF()->current_user_email = $topic['email']; + } + } +} // - allow to delete topics by anonymous user add_action('wp_ajax_nopriv_wpforo_delete_ajax', 'cbsonline_wpforo_nopriv_delete'); function cbsonline_wpforo_nopriv_delete() diff --git a/wpforo/layouts/2/post.php b/wpforo/layouts/2/post.php index fe70866..c357f90 100644 --- a/wpforo/layouts/2/post.php +++ b/wpforo/layouts/2/post.php @@ -35,6 +35,7 @@ }else{ $buttons = array( 'report', 'delete', 'link' ); } + wpforo_post_buttons( 'icon-text', $buttons, $forum, $topic, $post ); if (!is_user_logged_in()) { $forumid = (isset($forum['forumid'])) ? $forum['forumid'] : 0; $topicid = (isset($topic['topicid'])) ? $topic['topicid'] : 0; @@ -48,7 +49,6 @@ echo ''.wpforo_phrase('Delete', false).''; } } - wpforo_post_buttons( 'icon-text', $buttons, $forum, $topic, $post ); ?> @@ -64,6 +64,18 @@ perm->forum_can(($is_topic ? 'eot' : 'eor' ), $forumid) + && $diff < WPF()->post->options[($is_topic ? 'eot' : 'eor').'_durr']) { + $a = ( $is_topic ) ? 'wpfedittopicpid' : ''; + $b = ( $is_topic ) ? $topicid : $postid; + echo ''.wpforo_phrase('Edit', false).''; + } + } ?>