WordPress.org

Forums

[resolved] [Plugin: WordPress Popular Posts] to include both the logged in and non-logged in users? (8 posts)

  1. yelu27
    Member
    Posted 4 years ago #

    I have modified the src refer to this post ,
    finally,the reviews counts indeed include the logged-in users,but it also begins to ignore the non logged-in readers.My question is how to include both?

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

    Hi yelu27,

    Instead of changing this:

    add_action('wp_ajax_nopriv_wpp_update', array(&$this, 'wpp_ajax_update'));

    ... into this:

    add_action('wp_ajax_wpp_update', array(&$this, 'wpp_ajax_update'));

    ... (as mentioned in that post) you should keep them both, like this:

    add_action('wp_ajax_nopriv_wpp_update', array(&$this, 'wpp_ajax_update'));
    add_action('wp_ajax_wpp_update', array(&$this, 'wpp_ajax_update'));

    That way my plugin will update for both the logged and non-logged in users. You also need to keep the rest of changes mentioned on that post in order to make it work.

    Give it a try and let me know the results.

  3. yelu27
    Member
    Posted 4 years ago #

    thx,it works,and I will inform you if it causes some other problems.

  4. numaga
    Member
    Posted 4 years ago #

    Is this still working with the current version? I did what is told on both support topics but I can't get it to work. It only records the views of users that are not logged in. I really need to record the views members make as well. A large part of my daily visitors is logged in so I get really useless results now.

    Please advise.

  5. Bart McLeod
    Member
    Posted 4 years ago #

    I think it is pretty useless to have everyone hack your code to make your plugin really useful.

    Of course, with WordPress being a community and sharing tool, logged in users actions may matter as much or even more than non-logged in user actions.

    So which visits to track for popularity should be an option in the admin panel. I am willing to aid in making it optional that way.

  6. KendrickSnyder
    Member
    Posted 4 years ago #

    I'm having the same issue as @numage

    I updated line 62 to

    add_action('wp_ajax_nopriv_wpp_update', array(&$this, 'wpp_ajax_update'));
    add_action('wp_ajax_wpp_update', array(&$this, 'wpp_ajax_update'));

    and line 358 was already changed to

    if (! wp_verify_nonce($nonce, 'wpp-token') ) die("Oops!");

    anyone still having issues with the plug in not tracking the actions of logged in users? Anyone know of what can fix it?

    Thanks,

    Kendrick

  7. KendrickSnyder
    Member
    Posted 4 years ago #

    sorry,

    @numaga

    To be a little more descriptive of my issue - The plugin seems to recognize the activity of non-logged in users. It seems to work perfectly, except for the fact I want it to work with both logged in users and guests. anyone else having this issue? I tried the fix that was outlined in the previous posts, but just as numaga is having issues, so am I.

    I would be grateful for any help. Thanks.

  8. KendrickSnyder
    Member
    Posted 4 years ago #

    Ok,

    The tutorial leaves out one major part.. what you will need to do is...

    Line 62 & 63

    add_action('wp_ajax_nopriv_wpp_update', array(&$this, 'wpp_ajax_update'));
    add_action('wp_ajax_wpp_update', array(&$this, 'wpp_ajax_update'));

    Line 358 (The version I had already had this code changed)

    if (! wp_verify_nonce($nonce, 'wpp-token') ) die("Oops!");

    Line 474

    if ( is_single() || is_page() ) {

    Anyway, that is what worked for me.

    Great Plugin, BTW!

Topic Closed

This topic has been closed to new replies.

About this Topic