Getting disabled entity

Can some one help me find the code for getting all disabled or enabled=no entities in entities database.

  • You need to enable the hidden entities flag:


    $hidden_status = access_get_show_hidden_status(); // what the setting is currently

    access_show_hidden_entities(true); // enable show-hidden status

    // do something with hidden entities

    access_show_hidden_entities($hidden_status); // restore status to previous setting

  • Hi Matt


    Thanks, simply I need to get the guid of all entities which are disabled, do we have any option to list through elgg_get_entity() ?


    Can you help.



  • Yeah you can add:

    $options['wheres'][] = "e.enabled = 'no'";

    To the options for elgg_get_entities

  • How to make this work on elgg_get_entities_from_metadata?

    I actually need to get only enabled entities but it returns all of them, even disabled ones.

    here is code:

    $options = array(
                    'types' => 'object',
                    'subtypes' => 'box',
                    'limit' => 0,
                    'offset' => 0,
                    'metadata_value' => '300',
                    'order_by_metadata' => array(    'name' => 'sorting',
                                        'direction' => 'ASC',
                                        'as' => 'integer'),
                $options['wheres'] [] = "e.enabled = 'yes'";
    $batch = new ElggBatch('elgg_get_entities_from_metadata', $options);
  • Leave away the wheres line

    $options['wheres'] [] = "e.enabled = 'yes'";

    and it shouldn't return disabled entities.

  • I thought by default elgg_get_entities_from_metadata or elgg_get_entities returns only enabled entities but it does not.

    That's why I found this thread and tried adding wheres but even with it does not work.

    I'm trying to get ONLY enabled entities, NOT disabled.

  • I just tested with elgg_get_entities() and it works as expected.

    Do you have a


    before fetching the entities? If yes, this would result in also hidden (disabled) entities from getting returned.

    If this is not the case, which version of Elgg do you use? Have you tried also on the latest version of Elgg if you're not using it at the moment anyway?

  • I don't have:


    I think it could be elgg_get_entities_from_metadata, elgg_get_entities works fine but elgg_get_entities_from_metadata might be different.

    Can you test with elgg_get_entities_from_metadata?

    I'm on Elgg 1.8.20

  • I now also tested with elgg_get_entities_from_metadata() and it works as expected, i.e. disabled entities are not fetched. So, it works fine on Elgg 2.3.

    I also tested on Elgg 1.8 and it ALSO works correct! So, I don't see any faulty behaviour in Elgg core.

    Are you really sure that showing of hidden entities isn't enabled when you are fetching the entities? You could test with logging the access status in the error log by adding these lines before your usage of elgg_get_entities_from_metadata():

    $access_status = access_get_show_hidden_status();
    elgg_dump("Access status is ".$access_status, false, 'NOTICE');

    And you really should work on upgrading to a newer version of Elgg (at least 1.12 or even better 2.3) instead of staying on 1.8.

  • @iionly

    I know, we have started upgrading custom plugins to 1.9 and then up but it is slow.

    I think problem is these entities are created by admin so logged in as admin it pulls all of them.

    This will be nooby question but is enabled entity same as access_id of the entity?

    Access Id dropdown sets "enabled" or disabled status?