Redirect problem

Can anyone help me out. I added the wire to the river but when i post i get redirected to the wire.

What do i need to add to let it stay on the dashboard.

Here is the code:

<div id="content_area_user_title"><h2><?php echo sprintf(elgg_echo('welcome:user'), $_SESSION['user']->name); ?>, what're you doing?</h2></div>

<script>
function textCounter(field,cntfield,maxlimit) {
    // if too long...trim it!
    if (field.value.length > maxlimit) {
        field.value = field.value.substring(0, maxlimit);
    } else {
        // otherwise, update 'characters left' counter
        cntfield.value = maxlimit - field.value.length;
    }
}
</script>

        <form action="<?php echo $vars['url']; ?>action/thewire/add" method="post" name="noteForm">
                        <?php
                            $display .= "<textarea name='note' value='' onKeyDown=\"textCounter(document.noteForm.note,document.noteForm.remLen1,140)\" onKeyUp=\"textCounter(document.noteForm.note,document.noteForm.remLen1,140)\" id=\"thewire_large-textarea\">{$msg}</textarea>";
                $display .= "<div class='thewire_characters_remaining'><input readonly type=\"text\" name=\"remLen1\" size=\"3\" maxlength=\"3\" value=\"140\" class=\"thewire_characters_remaining_field\">";
                echo $display;
                echo elgg_echo("thewire:charleft") . "</div>";
                                echo elgg_view('input/securitytoken');
                        ?>
                        <input type="hidden" name="method" value="site" />
                        <input type="submit" value="<?php echo elgg_echo('save'); ?>" />
        </form>

<?php
$wire_user = get_input('wire_username');
                if (!empty($wire_user)) { $msg = '@' . $wire_user . ' '; } else { $msg = ''; }

echo elgg_view('input/urlshortener');
?>
<div class="clearfloat"></div>

  • The redirect is in the thewire/add action, which will be in elgg/mod/thewire/actions/add.php.  There's a forward() call that tells the actions where to forward back to.

  • // Forward back to the page from where post made

    forward($_SERVER['HTTP_REFERER']);

  • you can use the HTTP_REFERER call to forward it back to the page you came from.

    EDIT: WebG, you've got quick fingers!!!

  • @ Brett

    I saw the foward but now im still stuck

    forward("mod/thewire/everyone.php");

    @Team Webgalli

    If i add that line i get problems with login in 2 the website. U get in a loop.

  • @Clinton

    if you are using the standard riverdashboard change the forward to:

    forward("mod/riverdashboard/index.php");

    or

    forward("pg/dashboard");

    should work as well.

    That should take you back where you want.

  • @RPGRealms

    Where is the best place to add it? Under the save part are anywhere?

  • You are going to have to either edit the add.php file for thewire or figure some other way to handle the action because the forward takes place there.

    What I'd do is duplicate the add.php from the wire, rename it to something else and save it with your plugin. Then rather than call thewire add.php you call your copied version. In your copied version, replace the forward. This way you don't interfere with the normal thewire add action when it might be called by other functions.

  • @Clinton, I cant understand how you are getting the redirect loop?

  • Hi folks

    I've posted this here, because it's another problem with redirect. I'm fairly new to plugin writing. I have an action pay.php that 'works' because it does the action [involving curl and an external server] but it just displays a white page and doesn't redirect, no matter how I code it up..code below:

    <?php
    include ($_SERVER['DOCUMENT_ROOT']."/mod/cclite/cclite-common.php") ;

        // Make sure we're logged in (send us to the front page if not)
            gatekeeper();
            // Make sure action is secure
            action_gatekeeper();
            $touser = get_input('touser');
            $currency = get_input('currency');
            $quantity = get_input('quantity');
            $description = get_input('description');

    /*
    /pay/$input[1]/$registry/$input[2]/$input[3]
    */

    $input = array('pay',$touser,$quantity,$currency) ; // parameters supplied as array
    $cclite = cclite_contents($input) ;

    // display return from cclite...
    system_message($cclite);

    //forward(get_loggedin_user()->getURL());

    forward($_SERVER['HTTP_REFERER']);

    ?>

     

  • hey.....can any body resolve my redirection problem from a popup. when i am opening a popup, i have redirected that through action (written in start.php of profile module) but the after inserting the values, from action page it is not being redirected as desired instead of that it is being redirected on index page of "profile" module. ( Code: http://localhost/elgg-riplocas/pg/profile/Maron )

     

     

    Code is as follows:

    $url = $CONFIG->url . "pg/profile/".$username."/show_deceased_profile/?id=".$_REQUEST['deceased_profile_id'];

    forward($url);

     

    Please help me in resolving this issue.....its quite urgently needed