A Flarum extension. Mark a post as the best answer in a discussion. Original by @wiwatsrt.
- Allow Best Answers to be set and highlighted within a discussion
- Set which tags support Best Answer/Q&A format
- Filter answered/unanswered/all discussions within available tags
- Send reminders to the OP to select a Best Answer after a configurable number of days
- Optionally allow the OP to select one of their own follow-up posts as the Best Answer
- Provides two layouts for the Best Answer controls
- Option to prevent reminders from being sent overnight
- Flarum 2.x
- flarum/tags
These extensions are optional. When one is enabled, Best Answer adds:
- flarum/audit: an audit log entry when a best answer is set or unset.
- flarum/deck: Unsolved questions and Best answers columns. With flarum/realtime they follow best answers being set and removed as it happens.
- flarum/realtime: a live
bestAnswerEventbroadcast when a best answer is set or unset. - fof/user-directory: "Most best answers" and "Least best answers" sort options in the user directory.
- ianm/level-ranks: extra spacing beside the best answer label in post headers.
Install with composer:
composer require fof/best-answer:"*"The settings are on the FoF Best Answer page in the admin panel.
Best answers can only be set in discussions that have at least one Q&A tag. Choose these tags in Enabled Tags.
In a Q&A tag, the start discussion button reads Ask a Question. When a Q&A tag is selected in the composer, the title placeholder reads Question title.
Best answers can't be set in private discussions.
The permissions are in the Participate section of the Permissions page. Grant them globally, or per tag for restricted tags.
| Permission | Allows the user to |
|---|---|
| Select Best Answer (own Discussion) | Set or remove the best answer in discussions they started. |
| Select Best Answer (not own Discussion) | Set or remove the best answer in discussions started by others. |
| Select own post as Best Answer | Select one of their own posts. They also need one of the two permissions above. |
The select control isn't shown on hidden posts or on the first post of a discussion.
Turn on Display Best Answer filter dropdown to add a filter to the discussion list of each Q&A tag. It offers All questions, Solved questions and Unsolved questions.
In discussion search, is:solved finds discussions with a best answer and -is:solved finds discussions without one. is:question finds discussions in Q&A tags, so is:question -is:solved finds unsolved questions.
In post search, is:solution finds posts selected as a best answer.
A reminder is a notification that asks a discussion's author to select a best answer.
To send reminders:
- Set Days before reminding to the number of days to wait after a discussion is started.
0, the default, turns reminders off. - Choose the tags in Reminder Tags.
- Run the Flarum scheduler. Add a cron entry that calls
php flarum schedule:runevery minute, as described in the Flarum documentation.
The extension schedules the fof:best-answer:notify command to run hourly. php flarum schedule:list shows it. Each run reminds the author of every discussion that:
- has a reminder tag, and a tag from Enabled Tags
- was started between N and N + 7 days ago, where N is Days before reminding
- has at least one reply
- has no best answer, isn't hidden or private, and its author's account still exists
- hasn't been reminded before
The author must have the Select Best Answer (own Discussion) permission. If no one else has posted a reply the author could select, the author also needs Select own post as Best Answer. Hidden replies, replies awaiting approval and event posts, such as a tag change, don't count. A reply from a deleted account does.
Each discussion gets one reminder at most. Setting a best answer deletes the reminder.
With Don't send reminders overnight turned on, the command only runs between 08:00 and 21:00 UTC. With Log reminder runs turned on, the command's output is added to storage/logs/fof-best-answer.log.
| Setting | Effect |
|---|---|
| Alternative layout | Shows the select button in the post footer instead of the post's controls menu. |
| Max lines to show in post preview | The best answer is previewed under the first post. Longer answers are cut to this many lines. 0 shows the whole answer. |
| Tags for discussions with Best Answers | Secondary tags added to a discussion when a best answer is set, and removed when it is unset. |
| Display jump to Best Answer button in discussion sidebar | Adds a View Best Answer button to the discussion sidebar. |
Users choose how they receive these in their notification settings.
| Notification | Sent to | On by default |
|---|---|---|
| Someone sets my post as a best answer | The author of the selected post, unless they selected it | Alert |
| A best answer is set in a discussion I participated in | Other users who posted in the discussion | None |
| An automated reminder to select a best answer in a discussion I started | The discussion's author | Alert and email |
composer update fof/best-answerBefore this release, choosing a different best answer in a discussion left the previous answer's author with one best answer too many. After updating, recalculate every user's best answer count:
php flarum fof:best-answer:update-countsThe command goes through every user, so it can take a while on large forums.
An extension by FriendsOfFlarum.