Please or Register to create posts and topics.

Rating system for Threads/Posts

Page 1 of 2Next

Hello,

I was wondering if there’s already been developed a way to rate forum threads individually or if someone is already working on such implementation. Like you can give from 1 to 5 stars.

Otherwise it’s something maybe I’ll be developing soon, so tips and tricks are most welcome.

 

Thank you.

Hi Fillipe,

Use the hooks and any rating plugin

asgarosforum_after_post_message

 

 

Hello Filipe,

this feature is not integrated yet. As already mentioned by Yworld you can try to use one of the available hooks in combination with some rating-extensions to implement it by yourself. 🙂

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!
Quote from Yworld on July 26, 2017, 2:01 pm

Hi Fillipe,

Use the hooks and any rating plugin

asgarosforum_after_post_message

 

 

Thank you so much for your reply, I am still new to this plugin (this client brought it to my attention) so I would like to know if it had been already done or if it would be complex to implement and I decided to first look for the answer here.

Quote from Asgaros on July 26, 2017, 3:27 pm

Hello Filipe,

this feature is not integrated yet. As already mentioned by Yworld you can try to use one of the available hooks in combination with some rating-extensions to implement it by yourself. 🙂

Thank you, will definitely try that! 🙂

Hello again. Had been working on another project and I’m working on these tasks now.

 

This is my table forum_posts

http://prntscr.com/g3rtjj

To input the ratings, should I add another column (rating_id)? This is forum-database.php

$sql3 = "
            CREATE TABLE ".self::$table_posts." (
            id int(11) NOT NULL auto_increment,
            text longtext,
            parent_id int(11) NOT NULL default '0',
            date datetime NOT NULL default '0000-00-00 00:00:00',
            date_edit datetime NOT NULL default '0000-00-00 00:00:00',
            author_id int(11) NOT NULL default '0',
            author_edit int(11) NOT NULL default '0',
            uploads longtext,
            PRIMARY KEY  (id)
            ) $charset_collate;";

 

WP-PostRatings is the plugin I intend to use (https://lesterchan.net/portfolio/programming/php/#wordpress-wp-postratings). This is the rating plugin’s table:

Usage
Open wp-content/themes/<YOUR THEME NAME>/index.php
You may place it in archive.php, single.php, post.php or page.php also.
Find: <?php while (have_posts()) : the_post(); ?>
Add Anywhere Below It (The Place You Want The Ratings To Show): <?php if(function_exists('the_ratings')) { the_ratings(); } ?>
If you DO NOT want the ratings to appear in every post/page, DO NOT use the code above. Just type in [ratings] into the selected post/page content and it will embed ratings into that post/page only.
If you want to embed other post ratings use [ratings id="1"], where 1 is the ID of the post/page ratings that you want to display.
If you want to embed other post ratings results, use [ratings id="1" results="true"], where 1 is the ID of the post/page ratings results that you want to display.

 

My idea is to add another column with the stars from this plugin.

I don’t want to rate every reply, but every thread/post, like on this forum https://www.godlikeproductions.com/forum1/pg1

 

Would the hook in this case be

  • asgarosforum_after_add_thread_submit

 

For the column:

asgarosforum_custom_topic_column

Quote from Yworld on August 3, 2017, 10:41 am

For the column:

asgarosforum_custom_topic_column

Thanks!

 

I was also reading your response here https://asgaros.com/support/?view=thread&id=96

Yet another great contribution, by the way.

 

In my case I will be including it in includes/views/topic-element.php right?

I see it calls get_lastpost($lastpost_data, ‘thread’) from forum.php

Based on your post, this is what I put in topic-element.php

<?php 

function FunctionTopicRating($topic_id) {
    $topic_rating ='<div>Rating</div>'; //Here I will have to get the rating with topic_id - thus added rating_id column in database
    return $topic_rating;
}

add_action('asgarosforum_custom_topic_column', 'TopicRating', $thread->id);

function TopicRating($topic_id) {
    echo FunctionTopicRating($topic_id);
}

?>

Right above

<div class="topic-poster"><?php echo $this->get_lastpost($lastpost_data, 'thread'); ?></div>

Can you explain to me this add_action?

In your example you put

add_action('asgarosforum_custom_forum_column', 'ForumColumnAdvertisement', 10, 1);

Are 10 and 1 the id of the forums or is it somehow advertising and avatar (you ended up arrows to 2 extra columns in your example)?

 

OR

Could I simply add

<div>Rating <?php /*get the rating with the rating_id I will have in the thread table */ ?></div>

 

 

 

It’s better to use hooks, it will not be lost when upgrading

Example

Convenient to manage or add …

function FunctionForumRatingTop() {
  $rating_forum_top ='<div>Rating  the rating with the rating_id I will have in the thread table</div>';
  return $rating_forum_top;
}
add_action('asgarosforum_custom_topic_column', 'ForumRatingTop');
function ForumRatingTop() {
  echo FunctionForumRatingTop();
}

Example:

function FunctionForumRatingTop() {
  echo '<div>Rating get the rating with the rating_id I will have in the thread table</div>';
  
}
add_action('asgarosforum_custom_topic_column', 'FunctionForumRatingTop');

 

Quote from Yworld on July 26, 2017, 2:01 pm

Hi Fillipe,

Use the hooks and any rating plugin

asgarosforum_after_post_message

 

 

Hoy Yworld, could you tell me which plugin are you using on your example?

Page 1 of 2Next