Support » Plugin: Simple Calendar - Google Calendar Plugin » Next Month and admin access

  • Hi,

    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: (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.

Viewing 1 replies (of 1 total)
  • Plugin Contributor Ross Hanney


    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.

Viewing 1 replies (of 1 total)
  • The topic ‘Next Month and admin access’ is closed to new replies.