Creating User with a Ajax call

Hallo there,

I'm messing around with Elgg and need to create a new user within a serious of jQuery dialogues. My problem is that there is the setcookie function which redirects the browser to the frontpage.
This ruins the whole process of the dialog. I also implemented 2 hooks to set standard widgets and other stuff where the user gets logged in and out while the creation.

So my Question:

is there a possibility to avoid a redirection when using register_user()?
or do i have to reimplement the registration without the setcookie function?

i hope someone can help me.

thanks for every suggestion!

 

  • setcookie() is a built-in PHP function and doesn't redirect the page.  The redirect is from somewhere in Elgg's framework.

    Evan has been working on improving ajax support for 1.8.  He's solved part of the redirect problem by hooking into the forward, system plugin hook and overriding the return value.  Check out the forward() function in engine/lib/elgglib.php.

  • Thanks for the hint, I'll check it out!

  • Does it work when i overwrite this function as long as there is no solution not forwarding on a AJAX call? So write this function into my mod and adding a context called AJAX would probably be enought. Changing the Context inside my php file which is requested on the ajax call and changing it back afterwards.

    /* Killing Ajax redirect Bug */
    function forward($location = "")
    {
        global $CONFIG;
     
        if (!headers_sent() && get_context() != 'AJAX' )
        {
            $current_page = current_page_url();
            if ((substr_count($location, 'http://') == 0) && (substr_count($location, 'https://') == 0)) {
                $location = $CONFIG->url . $location;
            }
            header("Location: {$location}");
            exit;
        }
        return false;
    }

    I have to test it today.

    PS: No method overriding in PHP possible so i have to override the whole elgglib.php in my mod.

  • Doesn't work the way it should but i recognized there is a possibility to implement a hook in a newer version (1.7.4) of Elgg. :)

  • please could you tell me about the solution coz i need to stop redirecting after logout

    and i didn't get it now:(

    i think the problem is with $CONFIG array special at elgg_[url]

    try to print the value of array and then you can  get the trouple

    but until now  ididn't solve the problem to stop redirect after logout

    soo could you help me please ??