WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin: WordPress Popular Posts] Database not populating [with plugin requiring readers to be logge (6 posts)

  1. itsfridaymoanin
    Member
    Posted 4 years ago #

    I am using another plugin that requires readers to be logged in. (I'm using WordPress as an internal wiki collaboration tool). I was having problems getting the database to populate, but I finally got it to work, so I thought I'd post my solutions.

    First, I had to include <? wp_head(); ?> in the theme file header.php before the </head> tag.

    Secondly, this plugin is designed to record only page views of non-logged-in users (and for fair enough reasons, though it makes the plugin completely inept for my purposes). So a little code editing was in order:

    First, make the update fire on different hook (namely one that doesn't require non-logged-in status) Change code on line 54 of wordpress-popular-posts.php
    from:
    add_action('wp_ajax_nopriv_wpp_update', array(&$this, 'wpp_ajax_update'));
    to:
    add_action('wp_ajax_wpp_update', array(&$this, 'wpp_ajax_update'));

    Second, remove the requirement in wpp_ajax_update() that the user be logged out. So on line 337 of the same file, change the conditional
    from:
    if (! wp_verify_nonce($nonce, 'wpp-token') && !is_user_logged_in() ) die("Oops!");
    to:
    if (! wp_verify_nonce($nonce, 'wpp-token') ) die("Oops!");

    Just wanted to share! Great plugin.

    http://wordpress.org/extend/plugins/wordpress-popular-posts/

  2. H├ęctor Cabrera
    Member
    Posted 4 years ago #

    Hi there,

    Thanks you for taking the time to wirte this small "tutorial". Even though I already described this on another thread before, your explanation is much more concise and easy to follow.

    If you don't mind, I'm adding a link to this thread to the FAQ section so others can learn about this procedure.

    Once again, thanks for sharing!

  3. patung
    Member
    Posted 4 years ago #

    The instructions are a little out of date for the second part which might confuse some as the code has changed a bit, no 'oops die' for example, but ultimately it's just a matter of removing

    && !is_user_logged_in()

  4. patung
    Member
    Posted 4 years ago #

    Actually I'm a bit confused now, do the above modifications mean that BOTH logged in and non logged visitors are counted, or only logged in people? Because it doesn't seem to be counting non-logged in people now.

  5. patung
    Member
    Posted 4 years ago #

  6. superposts
    Member
    Posted 3 years ago #

    hi
    under the popular section on the left side bar i want to show the title of the post with the number of views not the comments.
    http://superposts.org/

    what is the parameter that i have to pass? currently i am using this code but it is not what i want.
    <?php if (function_exists('wpp_get_mostpopular')) wpp_get_mostpopular("range=all-time&order_by=views&exclude=comments"); ?>

    thanks

Topic Closed

This topic has been closed to new replies.

About this Topic