Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Remove the option to vote-down a question/answer

0 votes
71 views
asked Nov 28 in Q2A Core by sebastiaanspeck
How can I remove the vote-down button by the questions and answers?
Q2A version: 1.7.5

1 Answer

+3 votes
answered Dec 1 by pupi1985

Building on my previous answer: http://www.question2answer.org/qa/55614/how-to-make-it-impossible-to-remove-the-upvote?show=55618#a55618

There is no setting to do so. You'll have to modify code. This can be done with a layer (or even modifying the theme) and an override. However, here are the corehacks with the changes.

1. Edit qa-include/qa-theme-base.php

2. Locate function vote_buttons and edit it this way (this sets up the user interface and is just for cosmetic purposes):

Turn this:

case 'voted_down':
  $this->post_hover_button($post, 'vote_down_tags', '–', 'qa-vote-one-button qa-voted-down');
  break;

case 'voted_down_disabled':
  $this->post_disabled_button($post, 'vote_down_tags', '–', 'qa-vote-one-button qa-vote-down');
  break;

case 'up_only':
  $this->post_hover_button($post, 'vote_up_tags', '+', 'qa-vote-first-button qa-vote-up');
  $this->post_disabled_button($post, 'vote_down_tags', '', 'qa-vote-second-button qa-vote-down');
  break;

case 'enabled':
  $this->post_hover_button($post, 'vote_up_tags', '+', 'qa-vote-first-button qa-vote-up');
  $this->post_hover_button($post, 'vote_down_tags', '–', 'qa-vote-second-button qa-vote-down');
  break;

default:
  $this->post_disabled_button($post, 'vote_up_tags', '', 'qa-vote-first-button qa-vote-up');
  $this->post_disabled_button($post, 'vote_down_tags', '', 'qa-vote-second-button qa-vote-down');
  break;

Into this (just add the double slashes):

case 'voted_down':
//  $this->post_hover_button($post, 'vote_down_tags', '–', 'qa-vote-one-button qa-voted-down');
  break;

case 'voted_down_disabled':
//  $this->post_disabled_button($post, 'vote_down_tags', '–', 'qa-vote-one-button qa-vote-down');
  break;

case 'up_only':
  $this->post_hover_button($post, 'vote_up_tags', '+', 'qa-vote-first-button qa-vote-up');
//  $this->post_disabled_button($post, 'vote_down_tags', '', 'qa-vote-second-button qa-vote-down');
  break;

case 'enabled':
  $this->post_hover_button($post, 'vote_up_tags', '+', 'qa-vote-first-button qa-vote-up');
//  $this->post_hover_button($post, 'vote_down_tags', '–', 'qa-vote-second-button qa-vote-down');
  break;

default:
  $this->post_disabled_button($post, 'vote_up_tags', '', 'qa-vote-first-button qa-vote-up');
//  $this->post_disabled_button($post, 'vote_down_tags', '', 'qa-vote-second-button qa-vote-down');
  break;

3. Edit file qa-include/app/votes.php

4. Locate function qa_vote_set and add this:

if ((int)$vote === -1) {
  return;
}

Before this line:

require_once QA_INCLUDE_DIR.'db/points.php';
commented Dec 2 by q2apro
We definitely need a core option here... I am also still forced to use theme hacks.
...