Restricting Blog posting to Admin

I am pretty new to Elgg, but have been able to do most of what I have needed to either on my own or from posts on here.  I have an issue that I can't seem to get past, and can't find a suitable answer on here or anywhere else.

On a site I am doing I want to make it so that the Add blog post button on appears in the blog plugin for the admin.  I am pretty sure of what to do - putting the below around the button code:

if(isadminloggedin()){

// putting the code that makes the button appear here

}

 

My issue is I don't know where to put this code.  I can't seem to find where the button code exists in the blog plugin.

I am using Elgg version 1.8.2

Any help at all would be most excellent.  Thanks!

  • isadminloggedin() has been replaced by elgg_is_admin_logged_in()

    There are two things to do:

    1. Get rid of the button

    2. Restrict the edit form to admins (your users could still access the edit form even though there is no button)

     

    1. The button in the blog plugin is registered using:

    elgg_register_title_button();

    which in turn creates a "title:add" menu item.

    You should be able to use elgg_unregister_menu_item('title', 'add') in a specific context = 'blog'. If that doesn't work, create a custom plugin hook handler for 'register', 'menu:title' and return an empty array if the logged in user is not an admin. 

    2. You an extend the view 'forms/blog/save' with another view with a low priority, e.g.

    elgg_extend_view('forms/blog/save', 'my/view/before/the/blog/form', 1);

    Prirority of 1 will put your view before the form view. In your custom view, you can put something like admin_gatekeeper(); or if (!elgg_is_admin_logged_in()) forward();

     

     

  • Thank you so much!  That put me on the right track and looking the right areas to accomplish what I needed.

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking