Q&A Reputation Categories

I wanted to give Rep for posting questions and answers.

So, I added the following code to votes.php within the foreach function of the update_user_rep function:

// NEW Code Count user's answers
$answers_posted = $_qa_core->get_count( array(
'post_type' => 'answer',
'author' => $user_id,
) );

$total += $answers_posted * QA_ANSWER_PUB;

// NEW Code Count user's questions
$questions_posted = $_qa_core->get_count( array(
'post_type' => 'question',
'author' => $user_id,
) );

$total += $questions_posted * QA_QUESTION_PUB;

Additionally, I added the following code to qa.php under Reputation multipliers:

if (!defined('QA_ANSWER_PUB')) define( 'QA_ANSWER_PUB', 2 );
if (!defined('QA_QUESTION_PUB')) define( 'QA_QUESTION_PUB', 1 );

However, I’m not sure that question and answer posts are being recorded. Did I miss something?

  • Sajid

    Hi yudy,
    Hope you are doing good today :slight_smile:

    I am sorry but I am unable to detect what are you missing here. But please let me flag one of our SLS support staff here for their insight about this matter.

    Please bear in mind that their response time might be slower than the normal support staff since they work on most complex matters.

    Take care and have a nice day :slight_smile:

    Best Regards,

  • Lindeni Mahlalela

    Hello Dylan,

    We are very sorry for the late reply and we would like to extend our deepest apology for not replying on time.

    I went through the code and compared it with that of the plugin and found the following issues on your code. The way I understand your question and the code you provided, you want to give points to users who have posted questions and answers.

    For the Questions, you are counting the number of questions posted by the user and then you multiply that number by 'QA_QUESTION_PUB' which equals 1, this means 5 questions = 5 points

    Same thing for the answers but the multiplier is 'QA_ANSWER_PUB' which equals 2. So 5 answers = 5 points.

    If that is what you want to achieve, then your code looks should work 100% as expected. If you want to achieve something else other than this then you should consider adding custom post meta to the questions and answers and then use these meta to calculate what you want to calculate.

    According to the way I understand the code, you did not miss anything in terms of updating the points.

    I hope this answers your question.

    Please note that this plugin has been retired and so no longer supported. If you do need support in the future please consider on asking for help on public developer forums like Stack Overflow, there are people who can help there.


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.