Mark Posts as Best Answer [Deleted]

@Lior Thanks that did it great add on.

Where would I change the button colour of the best Answer so it sands out a bit more besides the other options

upload_2015-4-5_16-14-48.webp
 
Last edited:
@Lior. I seem to be running the following errors

Code:
Server Error Log
Error Info
ErrorException: Undefined index: thread_id - library/BestAnswer/Model/BestAnswer.php:181
Generated By: Unknown Account, Today at 12:57 AM
Stack Trace

#0 /home4/davem/public_html/library/BestAnswer/Model/BestAnswer.php(181): XenForo_Application::handlePhpError(8, 'Undefined index...', '/home4/davem/pu...', 181, Array)
#1 /home4/davem/public_html/library/BestAnswer/DataWriter/DiscussionMessage/Post.php(29): BestAnswer_Model_BestAnswer->recalculateBestAnswerForThread(Array)
#2 /home4/davem/public_html/library/XenForo/DataWriter/DiscussionMessage.php(590): BestAnswer_DataWriter_DiscussionMessage_Post->_messagePostSave()
#3 /home4/davem/public_html/library/XenForo/DataWriter.php(1409): XenForo_DataWriter_DiscussionMessage->_postSave()
#4 /home4/davem/public_html/library/XenMods/SameThreadFeed/Model/Feed.php(76): XenForo_DataWriter->save()
#5 /home4/davem/public_html/library/XenForo/Model/Feed.php(540): XenMods_SameThreadFeed_Model_Feed->_insertFeedEntry(Array, Array, Array)
#6 /home4/davem/public_html/library/XenForo/Model/Feed.php(567): XenForo_Model_Feed->_insertFeedData(Array, Array)
#7 /home4/davem/public_html/library/XenForo/Model/Feed.php(592): XenForo_Model_Feed->importFeedData(Array)
#8 /home4/davem/public_html/library/XenForo/CronEntry/Feeder.php(15): XenForo_Model_Feed->scheduledImportTimeLimited(15)
#9 [internal function]: XenForo_CronEntry_Feeder::importFeeds(Array)
#10 /home4/davem/public_html/library/XenForo/Model/Cron.php(357): call_user_func(Array, Array)
#11 /home4/davem/public_html/library/XenForo/Deferred/Cron.php(24): XenForo_Model_Cron->runEntry(Array)
#12 /home4/davem/public_html/library/XenForo/Model/Deferred.php(294): XenForo_Deferred_Cron->execute(Array, Array, 7.99999809265, '')
#13 /home4/davem/public_html/library/XenForo/Model/Deferred.php(428): XenForo_Model_Deferred->runDeferred(Array, 7.99999809265, '', false)
#14 /home4/davem/public_html/library/XenForo/Model/Deferred.php(373): XenForo_Model_Deferred->_runInternal(Array, NULL, '', false)
#15 /home4/davem/public_html/deferred.php(23): XenForo_Model_Deferred->run(false)
#16 {main}

Request State

array(3) {
  ["url"] => string(33) "http://mycatchat.com/deferred.php"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(3) {
    ["_xfRequestUri"] => string(44) "/threads/natural-cat-raw-cat-food-recipe.44/"
    ["_xfNoRedirect"] => string(1) "1"
    ["_xfResponseType"] => string(4) "json"
  }
}
 
@Lior. I seem to be running the following errors

Code:
Server Error Log
Error Info
ErrorException: Undefined index: thread_id - library/BestAnswer/Model/BestAnswer.php:181
Generated By: Unknown Account, Today at 12:57 AM
Stack Trace

#0 /home4/davem/public_html/library/BestAnswer/Model/BestAnswer.php(181): XenForo_Application::handlePhpError(8, 'Undefined index...', '/home4/davem/pu...', 181, Array)
#1 /home4/davem/public_html/library/BestAnswer/DataWriter/DiscussionMessage/Post.php(29): BestAnswer_Model_BestAnswer->recalculateBestAnswerForThread(Array)
#2 /home4/davem/public_html/library/XenForo/DataWriter/DiscussionMessage.php(590): BestAnswer_DataWriter_DiscussionMessage_Post->_messagePostSave()
#3 /home4/davem/public_html/library/XenForo/DataWriter.php(1409): XenForo_DataWriter_DiscussionMessage->_postSave()
#4 /home4/davem/public_html/library/XenMods/SameThreadFeed/Model/Feed.php(76): XenForo_DataWriter->save()
#5 /home4/davem/public_html/library/XenForo/Model/Feed.php(540): XenMods_SameThreadFeed_Model_Feed->_insertFeedEntry(Array, Array, Array)
#6 /home4/davem/public_html/library/XenForo/Model/Feed.php(567): XenForo_Model_Feed->_insertFeedData(Array, Array)
#7 /home4/davem/public_html/library/XenForo/Model/Feed.php(592): XenForo_Model_Feed->importFeedData(Array)
#8 /home4/davem/public_html/library/XenForo/CronEntry/Feeder.php(15): XenForo_Model_Feed->scheduledImportTimeLimited(15)
#9 [internal function]: XenForo_CronEntry_Feeder::importFeeds(Array)
#10 /home4/davem/public_html/library/XenForo/Model/Cron.php(357): call_user_func(Array, Array)
#11 /home4/davem/public_html/library/XenForo/Deferred/Cron.php(24): XenForo_Model_Cron->runEntry(Array)
#12 /home4/davem/public_html/library/XenForo/Model/Deferred.php(294): XenForo_Deferred_Cron->execute(Array, Array, 7.99999809265, '')
#13 /home4/davem/public_html/library/XenForo/Model/Deferred.php(428): XenForo_Model_Deferred->runDeferred(Array, 7.99999809265, '', false)
#14 /home4/davem/public_html/library/XenForo/Model/Deferred.php(373): XenForo_Model_Deferred->_runInternal(Array, NULL, '', false)
#15 /home4/davem/public_html/deferred.php(23): XenForo_Model_Deferred->run(false)
#16 {main}

Request State

array(3) {
  ["url"] => string(33) "http://mycatchat.com/deferred.php"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(3) {
    ["_xfRequestUri"] => string(44) "/threads/natural-cat-raw-cat-food-recipe.44/"
    ["_xfNoRedirect"] => string(1) "1"
    ["_xfResponseType"] => string(4) "json"
  }
}
Will contact you via a PC.

If i deactivated this add on (not deintall) i get this message if i create a new thread:



the same problem here: https://xenforo.com/community/threa...as-best-answer-cant-create-new-threads.88136/
The only thing I can suggest is to set a default value for the alternative_best_answers or disable STRICT_TRANS_TABLES, exactly as the this post suggests:
https://xenforo.com/community/threa...er-cant-create-new-threads.88136/#post-878181
 
Hello @Lior.

Is it possible to make the .bestAnswersList to be added/removed the same way that the BestAnswerIndicator is?

At the moment, i have to refresh the page to make it appear/disappear

Thanks :)
 
I'm not sure if this is by design, but the thread creator can also mark any of their own replies to their own thread as best answer. They do not have the "Mark any post as best answer" permission set either.

So to prevent people from creating threads and marking their own response as best answer, I done this in the best_answer_post_button template...

Find
Code:
<xen:if is="{$post.showBestAnswer}">

Replace
Code:
<xen:if is="{$post.showBestAnswer} AND {$post.user_id} != {$thread.user_id}">
 
I'm not sure if this is by design, but the thread creator can also mark any of their own replies to their own thread as best answer. They do not have the "Mark any post as best answer" permission set either.

So to prevent people from creating threads and marking their own response as best answer, I done this in the best_answer_post_button template...

Find
Code:
<xen:if is="{$post.showBestAnswer}">

Replace
Code:
<xen:if is="{$post.showBestAnswer} AND {$post.user_id} != {$thread.user_id}">
You have wrong Group Permission setup then as I don't have this issue.

Or using admin account? Then that's normal.
 
@RoldanLT The only permission the user has relating to best answers is "mark post as best answer" and NOT "mark any post as best answer". I did check a few times before posting. Not admin or mod either.



I checked 3 different accounts and created threads with them. They couldnt choose the OP, but could choose any of their other replies made in it.
 
Oh relax :P.
You should have missed something, check that user if it belongs to other secondary group.
 
I've just noticed another problem...

The bestAnswerList only shows up if the BA is on the same page as the OP. If the BA is not on page 1, then no link comes up below the OP.

I have it enabled in OPTIONS and like I say, it comes up fine but only if the BA is on page 1.

Also, if I also enable "embed in first post" in OPTIONS as well as the "below first post", but then disable the template mod for the embed, the BAL will come up as it should when the BA is not the same page as the OP.

So if...

OPTIONS:

Embed Best Answer in First Post - Disabled
Display Best Answer Link Under First Post - Enabled

...and BA marked on page 1...

bestAnswerList shows up below the OP (y)

... but if...

OPTIONS:

Embed Best Answer in First Post - Disabled
Display Best Answer Link Under First Post - Enabled

...and BA marked on page 2...

bestAnswerList DOESN'T show up below the OP (n)

...then if...

OPTIONS:

Embed Best Answer in First Post - Enabled
Display Best Answer Link Under First Post - Enabled

...and BA marked on page 1 or page 2...

bestAnswerList shows up below the OP (y)
BA is embedded in first post(y)

... then if...

OPTIONS:

Embed Best Answer in First Post - Enabled
Display Best Answer Link Under First Post - Enabled AND template mod for embed first post - Disabled

...and BA marked on page 1 or page 2...

bestAnswerList shows up below the OP (y)
BA is embedded in first post DOESN'T show up(y)

But then, if I disable the Embed Best Answer in First Post in options, even with the template mod already disabled. I'm back to square one with no bestAnswerList below OP if BA is on page 2 :confused:

Anyone else have this issue?
 
I'm not sure if this is by design, but the thread creator can also mark any of their own replies to their own thread as best answer. They do not have the "Mark any post as best answer" permission set either.

So to prevent people from creating threads and marking their own response as best answer, I done this in the best_answer_post_button template...

Find
Code:
<xen:if is="{$post.showBestAnswer}">

Replace
Code:
<xen:if is="{$post.showBestAnswer} AND {$post.user_id} != {$thread.user_id}">
That's by design, actually.

I've just noticed another problem...

The bestAnswerList only shows up if the BA is on the same page as the OP. If the BA is not on page 1, then no link comes up below the OP.

I have it enabled in OPTIONS and like I say, it comes up fine but only if the BA is on page 1.

Also, if I also enable "embed in first post" in OPTIONS as well as the "below first post", but then disable the template mod for the embed, the BAL will come up as it should when the BA is not the same page as the OP.

So if...

OPTIONS:

Embed Best Answer in First Post - Disabled
Display Best Answer Link Under First Post - Enabled

...and BA marked on page 1...

bestAnswerList shows up below the OP (y)

... but if...

OPTIONS:

Embed Best Answer in First Post - Disabled
Display Best Answer Link Under First Post - Enabled

...and BA marked on page 2...

bestAnswerList DOESN'T show up below the OP (n)

...then if...

OPTIONS:

Embed Best Answer in First Post - Enabled
Display Best Answer Link Under First Post - Enabled

...and BA marked on page 1 or page 2...

bestAnswerList shows up below the OP (y)
BA is embedded in first post(y)

... then if...

OPTIONS:

Embed Best Answer in First Post - Enabled
Display Best Answer Link Under First Post - Enabled AND template mod for embed first post - Disabled

...and BA marked on page 1 or page 2...

bestAnswerList shows up below the OP (y)
BA is embedded in first post DOESN'T show up(y)

But then, if I disable the Embed Best Answer in First Post in options, even with the template mod already disabled. I'm back to square one with no bestAnswerList below OP if BA is on page 2 :confused:

Anyone else have this issue?
This is a bug indeed which I've just fixed, thanks.
 
Thanks for continuing to update this fine addon.
May I make a request, please?
Plenty of people are using the Question prefix, but hardly anyone is marking a post as the best answer.
I think we need to prompt the OP to do so.

Could you please consider updating the addon to send an alert to the OP of a thread which has
  • got the Question prefix (so is therefore an unanswered question)
  • has x number of replies - a setting in the admin page - maybe 0 = do not send an alert
  • has had y days since reply number x was posted - another setting in the admin page
In other words after the question has had a certain number of replies and a certain number of days has passed since that reply was posted, send the alert.
The alert links to the thread and prompts the OP to mark one of the replies as best answer.
Thanks
 
Top Bottom