forward() function dosn't work, it does nothing, no error, no output, just nothing, why?


I'm a web developer. I started experimenting with Elgg in order to write my own plugin.
I use the Elgg version 1.7, and I have a small problem with te forward function in my code.

Basically I have created a
skeleton of the plugin. It's a small plugin initiative, but I think it should work right now, and I don't understand why it dosn't works.

The subject of my problem is the forward function (or method).
- I created the plugin folder in the mod directory
- ...created the start.php
- ...created action, views, languages folders etc.
- and I created some other php files in the root directory of my plugin too.
- I have a manifest xml too (I know this is just for information about the plugin, and
this does not affect anything, but I have this file too).

I have an add.php file in my plugin root, to add something to the database. It works fine, the data of my form (in views/defaults/myplugin/add) is submitting, and the add.php in my action folder creats the new ElggObject and save it into the database table correct, but on the end of the inserting in my add.php, where I use the forward function after the save(), to forward the user back to the main plugin page, happens nothing. I dont understand! Nothing, no error message, just nothing.
In my .htaccess I have the row: php_value display_errors 1, and it displays if there is an error in my code, but in this case there is no error message, or any notification, or else..

If I try to cut out everything from my plugin, and I try to keep just the core start.php, even then the forward function in the other plugins, and in other parts of the Elgg site is dead, and dont forward anymore.

Please help my, it's
very frustrating, what the heck could cause this!?

Thank you very much, and sorry for my bad english!

Here are some source codes for help understand, but I told, that if only the start.php exists, even then my problem with the forward function exists.

This is my start.php

global $CONFIG;


function myplugin_init()

global $CONFIG;

elgg_extend_view('css', 'myplugin/css');


if (isloggedin()) {

add_menu(elgg_echo('myplugin:myplugin'), $CONFIG--->wwwroot . "pg/myplugin");


function myplugin_page_handler($page)
global $CONFIG;

if (isset($page[0]))

if (isset($page[1]))

switch ($page[1])
case 'add' :
require($CONFIG->pluginspath . "myplugin/actions/add.php");

switch ($page[0])
case 'add' :
require($CONFIG->pluginspath . "myplugin/add.php");

case 'edit' :
require($CONFIG->pluginspath . "myplugin/edit.php");

case 'delete' :
require($CONFIG->pluginspath . "myplugin/delete.php");

case 'settings' :
require($CONFIG->pluginspath . "myplugin/settings.php");


else {
// Include the standard cars index
require($CONFIG->pluginspath . "myplugin/index.php");

return true;


this is my add.php in the plugin root


include_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");



$sidebar = elgg_view("myplugin/sidebar");

$content =elgg_view("myplugin/add");

// title
$main_content = elgg_view_title(elgg_echo("myplugin:create"));

$main_content .= elgg_view('page_elements/contentwrapper', array('body' =--> $content, 'subclass' => 'myplugin'));

$body = elgg_view_layout("sidebar_boxes", $sidebar, $main_content);

page_draw(elgg_echo('myplugin:myplugin'), $body);


and this is my form

$form_body .= "
".elgg_view('input/text', array('internalname' => 'brand'))." ".elgg_view('input/text', array('internalname' => 'type'))." ".elgg_view('input/text', array('internalname' => 'category'))." ".elgg_view('input/submit', array('value' => elgg_echo("myplugin:save")))."


<!--?php echo elgg_view('input/form', array('action' =--> "/pg/myplugin/action/add", 'body' => $form_body, 'internalid' => 'mypluginAddForm'));?>

and my add.php in action folder


// get the form input
$brand = get_input('brand');
$type = get_input('type');
$category = get_input('category');

if (empty($brand)){

if (empty($myplugin_type)){

if (empty($category)){

// Initialise a new ElggObject
$myplugin = new ElggObject();
// Tell the system it's a myplugin object
$myplugin--->subtype = "myplugin";
// Set its owner to the current user
$myplugin->owner_guid = get_loggedin_userid();
// Set it's container
$myplugin->container_guid = (int)get_input('container_guid', get_loggedin_userid());
// For now, set its access
$myplugin->access_id = $access;
// Set its properties
$myplugin->myplugin_brand = $brand;
$myplugin->myplugin_type = $type;
$myplugin->myplugin_category = $category;

// Now save the object
if (!$myplugin->save()) {
// Success message
// add to river
add_to_river('river/object/myplugin/create', 'create', get_loggedin_userid(), $myplugin->guid);

// Forward to the main myplugin page
$page_owner = get_entity($myplugin->container_guid);
if ($page_owner instanceof ElggUser) {
$username = $page_owner->username;
} else if ($page_owner instanceof ElggGroup) {
$username = "group:" . $page_owner->guid;


  • Are you checking your error log for Apache or wherever your PHP errors are going? If forward() is not working, it is usually because you are sending content to the browser before calling the function. You should see a already sent headers error in the log.

  • In the meantime, I noticed that something was wrong, and something went to the client-side. I checked it with if(headers_sent()) .... and yes, it was something.... some whitespace or whatever ...

    Finally I copied the original start.php from the Elgg blog plugin, emptied it, and hold just  the skeleton for my own start.php, and it works like a charm again.

    However ,thank you very much for your help Cash!! :)