Google Calendar Events
Next Month and admin access (2 posts)

  1. olivier_twwli
    Posted 2 years ago #


    I'm working on a website with a private area and where I restrain the access to the WP admin to the subscribers with this php function.

    add_action('admin_init', 'gkp_restrict_access_administration');
    function gkp_restrict_access_administration(){
        if ( current_user_can('subscriber') ) {
            wp_redirect( get_bloginfo('url') );

    When a member is connected, your plugin works perfectly.
    However when we are disconnected, if you click on the arrow for viewing the next month, something really strange happens: you have all the content of my website instead of the plugin! Looks like a frame.

    You can see the result here: http://www.ps-tourscentre.fr/ (right column)

    Any ideas?


    Note: Apparently, it's not a conflict with a plugin or with another php function... I had disactivated all my plugins and functions to test my website.


  2. Ross Hanney
    Plugin Contributor

    Posted 2 years ago #

    Hello Olivier,

    When clicking on the month navigation links, the plugin sends its Ajax requests to wp-admin/admin-ajax.php (a bit odd for front end stuff, I know, but this is the recommended method). In admin-ajax.php, the admin_init action is fired, therefore calling your hooked function, which then redirects the request to the homepage. So the Ajax request ends up getting the homepage as a response.

    WordPress sets a constant called DOING_AJAX to true during Ajax requests. I'm not sure exactly what you're trying to achieve with your code, but perhaps you could check this constant in order to behave differently for Ajax requests?

    I hope that helps. If you have further questions, let me know.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Google Calendar Events
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic