0

Does any one have an example of how to submit data to an outside site from the form submitted on signup using the Solspace User Module.

I have my cURL code nailed (calling from another page), but have not been able to send the form data to that CURL script after successful submit. I need to include this to fire off: require_once("/base/cleintapps/mysubmit.php"); <- this is where I am sending data through CURL.

Thinking it's the user_register_end hook but have not been able to get it working. No matter how many times I look at and try the EE docs, I don't get how to put a hook together. I simply want to submit the info, including the custom fields. Thanks!

3

You need to craft an extension for that hook.

https://ellislab.com/expressionengine/user-guide/development/extensions.html

This guide is pretty thorough... did you make sure to install your extension after you made it? If it's not in the

exp_extensions

table, your extensions method won't get fired on that hook. Could you post your extensions contents (here or on a pastie site like pastebin and share) so we can help you? I will edit my answer once I see what you've done so far.

Edit

Here's some changes you need to make to your extension file. First, you have to give your method a name! And you need to allow it to accept the required parameters from the hook, even if you don't use them:

https://solspace.com/docs/user/extension_hooks/#user_register_end

public function my_submit ($user_ob, $member_id)
{
    // add code for the user_register_end hook here.
    require_once("/base/cleintapps/mysubmit.php"); 
}

Then you have to make sure you are telling ExpressionEngine to use that method when the hook is called (notice the 'method'=>'my_submit' part):

public function activate_extension()
{
    // Setup custom settings in this array.
    $this->settings = array();

    $data = array(
        'class'     => __CLASS__,
        'method'    => 'my_submit',
        'hook'      => 'user_register_end',
        'settings'  => serialize($this->settings),
        'version'   => $this->version,
        'enabled'   => 'y'
    );

    $this->EE->db->insert('extensions', $data);         

}   

And you need to make sure this extension file is called:

ext.send_external_data.php

and lives in this folder:

/your_website_html_root/system/expressionengine/third_party/send_external_data

Depending on how the User module handles hook calls, you might need to add

return;

or

return $user_ob;

after your require_once call inside of that function. Make sure that you disable this extension, make the changes (specifically the 'method'=>'my_submit' part) to this file, and reinstall it via the

Add-Ons -> Extensions

menu in your ExpressionEngine control panel. The extension table has a column called method, and if you don't get your method name in that cell ('my_submit' or whatever you choose), ExpressionEngine won't call your function. Let me know how it goes, and feel free to update your code pastie if it still isn't working, and I'll gladly suss it out for you!

| improve this answer | |
  • It's what you have probably heard a 1000 times, I am not a programmer Jim, I'm a marketer dangit lol. Seriously I am trying, I have posted the code here link. I feel like it's missing something huge and no matter how many times I read those docs over months now, I don't get it, I would like to but it evades me. I hope you can see what I have done wrong. Thanks! – Vin Jun 4 '15 at 21:27
  • Hooray! Thank you for helping me :) That worked, first extension under my belt. I have a much better grip on what is happening now more so than in the last years of trying to figure it out between projects. Also, I did not have to put a return; or return $user_ob; My final extension file is here link if you see anything glaring please let me know. Again very grateful for your help. – Vin Jun 5 '15 at 4:37
  • Glad I could help! Keep rolling out those extensions! – jrothafer Jun 5 '15 at 12:10
1

Along with having the naming conventions correct and the files in the right place, mentioned above. I see a couple of things that jump out at me. 1) in the activate extension method, the value for 'method' is blank. this tells the extension what function to run when the hook fires. It should read something like: 'method' => 'send_my_data'.

$data = array(
            'class'     => __CLASS__,
            'method'    => '',
            'hook'      => 'user_register_end',
            'settings'  => serialize($this->settings),
            'version'   => $this->version,
            'enabled'   => 'y'
        );

2) There is no name for the function which calls your curl code. See:

public function ()
    {
        // Add Code for the user_register_end hook here.
        require_once("/base/cleintapps/mysubmit.php"); 
    }

should be

public function send_my_data()
    {
        // Add Code for the user_register_end hook here.
        require_once("/base/cleintapps/mysubmit.php"); 
    }

what ever's in here (mysubmit.php) could be written in the method without including it. What's it look like? not sure what version of EE but

$this->EE->db->insert('extensions', $data);

should be

ee()->db->insert('extensions', $data);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.