WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Access Control
Website stops working when activating this plugin (5 posts)

  1. testlink25
    Member
    Posted 2 years ago #

    as soon as I activate this plugin, I get this error:

    Fatal error: Call to undefined function is_user_logged_in() in /wp-content/plugins/wordpress-access-control/wordpress-access-control.php on line 774

    any clue, I'm running other plugins as well including BPS Security and others.
    when I try to uninstall all plugins and lock an empty page, it locks my entire site and redirects to login page when I go to the homepage.

    http://wordpress.org/extend/plugins/wordpress-access-control/

  2. testlink25
    Member
    Posted 2 years ago #

    the fact that it locks my entire website is my bad, the box (make blog member only)
    and just discovered that It's not compatible with the plugin WP USER FRONT END.

  3. testlink25
    Member
    Posted 2 years ago #

    actually the error Fatal error: Call to undefined function is_user_logged_in() in /wp-content/plugins/wordpress-access-control/wordpress-access-control.php on line 774 is triggered when i turn on the plugin WP USER FRONTEND.

  4. theilldk
    Member
    Posted 2 years ago #

    Thanks..... I a HHTP-500 error pretty critical.

    And my error too was the WP user frontend

  5. professor99
    Member
    Posted 1 year ago #

    This is actually caused by a slight Access Control bug.

    Access Control hooks the WordPress get_page() function during plugin load. Unfortunately it calls the pluggable function is_user_logged_in() which means it will crash WordPress if any other plugin calls this function after during plugin load.

    Code from wordpress-access-control.php.

    add_filter( 'get_pages', array( 'WordPressAccessControl', 'get_pages' ) );
    ...
    class WordPressAccessControl
    {
    ...
    	function get_pages( $pages )
    	{
    		// Don't affect the display of pages when viewing the list in the admin
    		if ( is_admin() ) {
    			return $pages;
    		}
    
    		// Whether or not the user is logged in
    		$auth = is_user_logged_in();
    ...
    	}
    ...
    }

    The ideal solution is to obtain the user id without using the pluggable functions and apply this hook before the plugins load but this isn't so easy (try following the trail in pluggable.php).

    A less perfect solution is to forgo the filtering of the pages during plugin load and apply the action hook at high priority at the action hook 'init' which occurs after pluggables have been loaded and the user has been authenticated as follows.

    New code (NB delete old get_pages filter)

    add_action( 'init', array( 'WordPressAccessControl', 'add_get_page_hook' ), 0 );
    
    class WordPressAccessControl
    {
    ...
      function add_get_page_hook()
      {
        add_filter( 'get_pages', array( 'WordPressAccessControl', 'get_pages' ) );
      }
    ...
    }

    However there is the slight risk that other plugins with this hook at priority 0 that use get_page will miss out. You can use the following code to remove that possibility but no guarantees it will be future proof. It simply does what $wp->init() does in wp-settings.php a little bit earlier to no ill effect.

    New code (NB delete old get_pages filter)

    add_action( 'after_setup_theme', array( 'WordPressAccessControl', 'add_get_page_hook' ), 0 );
    
    class WordPressAccessControl
    {
    ...
      function add_get_page_hook()
      {
        wp_get_current_user();
    
        add_filter( 'get_pages', array( 'WordPressAccessControl', 'get_pages' ) );
      }
    ...
    }

    As far as I can see this is the only Access Control hook that has this problem.

    As to other plugins that cause this problem the one that has the most reports is WP User Frontend Version 1.1 but there is a new development version of this that fixes the problem.

    Cheers
    TheProfessor

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic