[Elgg 1.8-1.12 & 2.X: Login required] v1.9.6

Release Notes

Changes of version 1.8.6 ported to Elgg 1.9 version:

  • Fix in loginrequired_index() function parameter name to match variable name later used (though this error shouldn't have mattered as the loginrequired index page should be served with highest priority anyway),
  • The pages allowed to be visited when logged out by default by the Loginrequired plugin now include all pages also defined as public pages by Elgg's walled_garden mode (almost all apart from some specific pages were already included anyway),
  • Some minor code cleanup.
  •  Hi, I would like to make specific parts puplic. I followed your instructions and achieved that the blog page is public. However, without any of the blogs beeing listed..
    My problem is, that members still do not have the option to select "access: public" but only "private/friends/logged in".

    Can I somehow change this or is it simply not possible?

        $add[] = 'privacy';
        $add[] = 'about';
        $add[] = 'blog';
        $add[] = 'blog/all';
        $add[] = 'blog/featured';
        $add[] = 'blog/view/16212/test_blog';           

    Despite my question, the plugin is very usefull for me and works well. thanks

  • @Basti Schmidt The Loginrequired plugin unregisters ACCESS_PUBLIC from the access level selection to avoid any confusion by offering an access level that is of no use (at least under the conditions you would normally use a walled garden plugin where you wouldn't offer any content for anonymous visitors).

    To make it possible again to select "public" access level for content you would have to comment out a few lines in the init funtion in start.php (the bold lines):

    //    global $CONFIG;

        elgg_extend_view('css/elgg', 'loginrequired/css');

    //    if ($CONFIG->default_access == ACCESS_PUBLIC) {
    //        $CONFIG->default_access = ACCESS_LOGGED_IN;
    //    }
    //    elgg_register_plugin_hook_handler('access:collections:write', 'all', 'loginrequired_remove_public_access', 9999);

    Additionally, you should delete the file mod/loginrequired/views/default/groups/edit/access.php which overrides the corresponding Elgg core view with a modified version that removes the "public" access level for group content.

    With these changes the "public" access level will be a choice again for any type of content (not for blogs only) though.

    Depending on what pages / blogs you want to make public you could also add

    $add[] = 'blog/.*';

    Then you wouldn't have to make every blog posting public specifically (e.g. by $add[] = 'blog/view/16212/test_blog').

  • @iionly Awesome! Thank you so much..It works now as I wanted.

    With these changes the "public" access level will be a choice again for any type of content (not for blogs only) though.

     You are right. Thats actually a problem. I will try to find a solution for that. Any ideas welcome as I am not very experianced..Maybe an if statement, that checks if the current site is part of the public pages ($add) before unregistering ACCESS_PUBLIC from the access level selection.
    If this gets to complex, I will just try to unregister ACCESS_PUBLIC manually for the plugins and widgets where i don´t want it (e.g. activity profile widget, ...), if possible.

  • The "public" access level of a content item is not the same as a "public page". The content item-specific access level defines the accessibility / visibility of this specific item. But with a walled-garden the whole page is shielded from the visitors who are not logged in. A page being a "public page" does not define the visibility of content items within this page though, so you can't use the array of these pages to implement a condition.

    What might work in your case (as far as I know you only want the provide the users the option to make blogs public) is checking the context. In start.php at the end in the function loginrequired_remove_public_access() you could check if the plugin hook was triggered within the "blog" context and if this is the case you would not remove the "public" access level:

    // Remove public access
    function loginrequired_remove_public_access($hook, $type, $accesses) {

        if (elgg_get_context() != "blog") {
            if (isset($accesses[ACCESS_PUBLIC])) {
        return $accesses;

    This change will allow all users to make all their blog postings public and if you have added the corresponding blog pages to the array of public pages these blogs will be viewable when not logged in.


  • Category: Misc
  • License: GNU General Public License (GPL) version 2
  • Updated: 2016-12-11
  • Downloads: 8168
  • Recommendations: 26

Other Projects

View iionly's plugins