By Ignacio on Sunday, 31 May 2020
Replies 2
Likes 0
Views 1.6K
Votes 0
Hello,

As far as I can see who can accept answer in easydiscuss is controlled by user group.
I wanted to set it so that only the person who posted the question can accept the answer, and I found some tickets about this issue without a solution. I came up with the following solution.

I share it so that others can use it, and for the Easydiscuss team to evaluate it. Please tell me if it's a good solution.
Thank you!

Change the file: components/com_easydiscuss/themes/wireframe/post/default.actions.php

Add the following code in the line 59 under <?php if ($post->canAcceptAsAnswer()) { ?>


<?php
$usert = JFactory::getUser()->id;
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('parent_id');
$query->from('#__discuss_posts');
$query->where('id =' . $post->id);
$db->setQuery($query);
$parentidet = $db->loadObjectlist();
$postp = $parentidet[0]->parent_id;

$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('user_id');
$query->from('#__discuss_posts');
$query->where('id =' . $postp);
$db->setQuery($query);
$idet = $db->loadObjectlist();
$userp = $idet[0]->user_id;

$userad = JFactory::getUser();
$groups = $userad->get('groups');
foreach($groups as $group) {
if( $group == 8 or $userp == $usert){ ?>



And don't forget to add another two } above the line <?php if ($post->canReply()) { ?>

so that it looks like:


<?php }}} ?>


By doing this only users in user group 8 and question owner can accept answer.

Please let me know if it's a good idea to use this solution.

Thank you!
Love Stackideas.
Awesome Ignacio! Thank you for your efforts and sharing this to the community! We need more people like you

By the way, from what I can see in the codes, EasyDiscuss already allows the post owner to mark reply as an answer, https://take.ms/OhYY7

Am I missing anything here?
·
Sunday, 31 May 2020 11:24
·
0 Likes
·
0 Votes
·
0 Comments
·
Thank you Mark, awesome support as always.

I wanted a way so that, of the registered users group, only post owners can accept an answer and I thought that disabling the ACL option "Select Reply As Answer" would disable it for every question, even their own.

I can see now, that to achieve what I wanted, I only had to set the ACL to disabled.

Maybe you could change the field description from "User will not be allowed to set reply as an answer to question" to "User will only be allowed to set reply as an answer in questions posted by them" or somethimn like that in COM_EASYDISCUSS_ACL_OPTION_MARK_ANSWERED_RESULT_NO


So, in short, no need to change the files, the option is available via Easydiscuss Admin Options.

Excellent work!

Thank you!
·
Monday, 01 June 2020 05:43
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post