Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9125607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:50:36+00:00 2026-06-17T06:50:36+00:00

From the front end, I want to allow the author to pick up the

  • 0

From the front end, I want to allow the author to pick up the best comment/answer of his post. I am close, but not there yet. Every time I click the button, all comments of that post are selected as best (this is wrong). It should only select one comment per post.

In function.php I have the following:

add_action ('comment_post', 'add_comment_field', 1);
function add_comment_field($comment_id) {
    add_comment_meta($comment_id, 'bestanswer', 'no', false);
}

In comment.php I have the following:

<?php
    $current_author = get_the_author_meta('nickname');
    global $current_user; get_currentuserinfo();
    if ($current_user->nickname == $current_author) {
?>
<?php
    $my_post_meta = get_comment_meta($comment->comment_ID, 'bestanswer', true);
    if ( $my_post_meta == 'yes' ) {
            echo '<h4>Best answer</h4>';
        } else {
        ?>
        <form method="post" action="" id="bestanswer-<?php comment_ID() ?>">
            <input type="submit" name="confirm" value="Best Answer" />
        </form>
        <?php   

        if (isset($_POST['confirm'])) {
            update_comment_meta($comment->comment_ID, 'bestanswer', 'yes');
        }

    }
?>

Thoughts? Suggestions? Any help will be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:50:38+00:00Added an answer on June 17, 2026 at 6:50 am

    I solved this by adding a link to each comment. The link goes to a page that displays that comment. On this page, the author then selects the comment as best answer. Now the comment meta is only saved for that particular comment. I know is an extra step, but I prefer this method since the author has to make sure that that is the comment he wants to pick. Once the comment is selected as best, author cannot change it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to Switch from Web Designer to Front End Developer or web developer
Trying to write a javascript bookmarklet to jump from a front end link into
I have a Wordpress Front End Form to Publish/Draft Posts directly from my theme:
I am a front-end developer writing a C# application to export data from an
Through the front end I want to insert NULL value to the Column whose
I have column in a table that allow null but i want to make
I need to compare current day with some value. Like from front end I
I want to control the NodeInspector Front-End. It is itself designed to control Node.js
in my Android app, I observed that the video recorded from the front camera
How in the world do you create a custom front? Almost straight from the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.