One recurring task of any plugin will be to determine the page ownership in order to decide which actions are allowed or not. Elgg has a number of functions related to page ownership and also offers plugin developers flexibility by letting the plugin handle page ownership requests as well.
Determining the owner of a page can be determined with page_owner(), which will return the GUID of the owner. Alternatively, page_owner_entity() will retrieve the whole page owner entity. If the page already knows who the page owner is, but the system doesn't, the it be can set by passing the GUID to set_page_owner().
As mentioned, plugin developers can create page owner handlers, which could be necessary in certain cases, for example when integrating third party functionality. The handler will be a function which will need to get registered with add_page_owner_handler() by passing it the handler function name. The handler will only need to return a value (an integer GUID) when it knows for certain who the page owner is.
By default, the system determines the page_owner from the following elements:
username URL parameter owner_id URL parameter It then passes off to any page owner handlers defined using add_page_owner_handler(). If no page owner can be determined, the page owner is set to 0, which is the same as the logged out user.
Last updated 533 days ago by Pete Harris
