Helper functions
Contents
Input and output
get_input($name)
Grabs information from a form field (or any variable passed using GET or POST). Also sanitises input, stripping Javascript etc.set_input($name, $value)
Forces a value to a particular variable for subsequent retrieval byget_input()
Entity methods
$entity->getURL()
Returns the URL of any entity in the system$entity->getGUID()
Returns the GUID of any entity in the system$entity->canEdit()
Returns whether or not the current user can edit the entity$entity->getOwnerEntity()
Returns the ElggUser owner of a particular entity
Entity and context retrieval
elgg_get_logged_in_user_entity()
Returns the ElggUser for the current userelgg_get_logged_in_user_guid()
Returns the GUID of the current userelgg_is_logged_in()
Is the viewer logged inelgg_is_admin_logged_in()
Is the view an admin and logged inelgg_gatekeeper()
Shorthand for checking if a user is logged in. Forwards user to front page if notelgg_admin_gatekeeper()
Shorthand for checking the user is logged in and is an admin. Forwards user to front page if notget_user($user_guid)
Given a GUID, returns a full ElggUser entityelgg_get_page_owner_guid()
Returns the GUID of the current page owner, if there is oneelgg_get_page_owner_entity()
Like elgg_get_page_owner_guid() but returns the full entityelgg_get_context()
Returns the current page’s context - eg “blog” for the blog plugin, “thewire” for the wire, etc. Returns “main” as defaultelgg_set_context($context)
Forces the context to be a particular valueelgg_push_context($context)
Adds a context to the stackelgg_pop_context()
Removes the top context from the stackelgg_in_context($context)
Checks if you’re in a context (this checks the complete stack, eg. ‘widget’ in ‘groups’)
Plugins
elgg_is_active_plugin($plugin_id)
Check if a plugin is installed and enabled
Interface and annotations
elgg_view_image_block($icon, $info)
Return the result in a formatted listelgg_view_comments($entity)
Returns any comments associated with the given entityelgg_get_friendly_time($unix_timestamp)
Returns a date formatted in a friendlier way - “18 minutes ago”, “2 days ago”, etc.
Messages
elgg_register_success_message($message)
Registers a success messageelgg_register_error_message($message)
Registers an error messageelgg_view_message($type, $message)
Outputs a message