Support » Plugin: Spam protection, AntiSpam, FireWall by CleanTalk » Wrong using get_current_user_id function

  • Resolved ioannup


    In your plugin, you try to get get_current_user_id() earlier than it’s possible. It’s always 0 in this place. You can check wp-settings.php file where your code is running and then, it includes pluggable.php file where defining get_current_user_id function
    That’s why your plugin has a lot of issues with other plugins in Admin area if Custom contact forms setting is enabled.
    So, you can use get_current_user_id function only at least after plugins_loaded action.

    • This topic was modified 1 year, 6 months ago by ioannup.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support alexandergull


    Hello, @ioannup.

    Thank you for your feedback.

    We will discuss your suggestion with the team.

    And we will let you know about results.

    Be well,

    Plugin Author Safronik



    Fixed! Thank you so much for pointing on this flaw!
    Unfortunately we can’t use plugins_loaded hook for our purposes. So we made ours apbct_wp_get_current_user().

    You can see all changes here:

    Contact us if you have questions or suggestions.

    @safronik @alexandergull
    You are directly changing the global variable in the new method i.e. apbct_wp_get_current_user() which causes some hooks like set_current_user to not run at all. This can cause problems for other plugins who rely on that hook.
    Also, if I’m not mistaken modifying global variables is against the WordPress development guidelines as well.
    If possible please use this method instead wp_set_current_user().

    Plugin Support sergecleantalk



    I’ve transferred your request to our developers. They will answer you within 1-2 working days.

    Plugin Support sergecleantalk


    Thank you for your reply. We will fix this.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Wrong using get_current_user_id function’ is closed to new replies.