Post Voting disable voting based on date

Hi,

Just wanted to check if there is a way, using a shortcode/hook or custom code, of us adding functionality so you can specify an end date for voting on a post?

Even better would be a Start and End date

Also if there is we would need to include a countdown to when the voting Starts and Ends directly above or under the post.

Regards
SteveB

  • pxwm

    Hi @Jack Kitterhing

    I'm well thanks.

    Many thanks for the prompt reply and for flagging to @Vladislav.

    If @Vladislav confirms it isn't currently available it would be good to know if I could add some bespoke code in the interim or if there any hooks as per A+ whilst it is being considered as a feature request?

    If I can add some bespoke code it would be great if I could be given some guidance.

    Regards
    SteveB

  • pxwm

    Hi @Jack Kitterhing

    Any update from @Vladislav?

    I would also appreciate if he could also consider the following:-

    Does the Post Voting plugin allow us to create multiple custom post categories that would effectively allow the votes to be independent by categories?

    i.e. We want to be able to run multiple custom post categories at any one time and to be able to list the posts within these categories by order of vote independently of each other.

    So effectively the settings in the Post voting plugin are across all the custom post categories but the results of the votes are per category

    Would you suggest this would require a category setting within the plugin?
    If you agree then is there a way we can add some bespoke code to achieve or would it require an upgrade to the plugin?

    Regards
    SteveB

  • Vladislav

    Hello,

    I'm really sorry for such a long delay. The scheduled voting should be achievable with something like our scheduled content plugin (https://premium.wpmudev.org/project/scheduled-content/) or perhaps something like http://wordpress.org/plugins/schedule-your-content/ - this kind of approach would assume the use of the shortcode form of the post voting (so, not the automated injection approach). Do you think this could be useable in your scenario?

    As for the categories filtering, this isn't currently supported out of the box. However, the post votes are recored per-post, so it would be quite possible to combine the WordPress standard admin filtering posts by categories and this kind of information by, say, adding a custom column with post votes to your posts list (wp-admin/edit.php) with a bit of custom code.

  • pxwm

    Hi @Vladislav

    Many thanks for the feedback and I've reviewed your scheduled-content plugin.

    Looks good but I'm not sure if the client wants to post the article(s) earlier than the voting date so it can be read but not voted on until the voting start date.

    Also it would be nice to display the article with a countdown counter to when readers can vote.

    Does your scheduled-content plugin allow this or will it only show the article on the start date?

    I would also appreciate if you could confirm my understanding of your comment:-

    this kind of approach would assume the use of the shortcode form of the post voting (so, not the automated injection approach).

    Does this mean I would have to add the post voting shortcode within the body of the article?

    As for the Categories requirement are you able to provide us with some guidance on the custom code we would need to add to the wp-admin/edit.php file?

    Regards
    SteveB

  • Vladislav

    Hello,

    Our scheduled content plugin can show the timer, and even reload the page when it's time to reveal the content (you can check the usage tab for a bit more details and some screenshots). But yes, this approach would require adding the voting to the post body, in the shortcode form.

    Lastly, as for the custom code, I'm sorry for the confusion, I probably haven't explained myself very well. The wp-admin/edit.php is just the list page URL, I was just mentioning this to explain what post listing page I was on about. Since this is a core WP file, I don't actually recommend editing it, otherwise your future core updates (which are *highly* recommended) won't be as easy. Anyway, having said that, here's an example code that will add the column I was mentioning earlier and populate it with the current number of votes:

    class Pv_Votes_Column {
    
    	private $_model;
    
    	private function __construct () {
    		$this->_model = new Wdpv_Model;
    	}
    
    	public static function serve () {
    		$me = new self;
    		$me->_add_hooks();
    	}
    
    	private function _add_hooks () {
    		add_filter('manage_edit-post_columns', array($this, 'add_columns'));
    		add_action('manage_post_posts_custom_column', array($this, 'fill_up_columns'), 10, 2);
    	}
    
    	public function add_columns ($cols) {
    		$cols['votes'] = "Votes";
    		return $cols;
    	}
    
    	public function fill_up_columns ($column, $post_id) {
    		if ("votes" !== $column) return false;
    		global $post;
    		echo $this->_model->get_votes_total($post->ID);
    	}
    }
    add_action('plugins_loaded', array('Pv_Votes_Column', 'serve'));

    You can add this code to your functions.php or to a mu-plugin. Once that's done, you should be able to see the votes for each post within a category on in your admin area, by following the "Posts" column link from your Posts > Categories listing - e.g. /wp-admin/edit.php?category_name=uncategorized Can you please give that a go and see if it helps?

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.