Support » Plugin: YOP Poll » Also submit custom fields to contact management software.

  • Resolved DreamsFulfilledAgents

    (@dreamsfulfilledagents)


    I was wondering where I can go in the YOP Poll files to make a little modification. What I’m trying to do is have it run as it is currently, but in addition to it’s current functionality, also feed custom fields to a contact management database. I’ve got a contact form that does this, I just need to know how to send the data captured from the YOP Poll to both the YOP database in WordPress so users can view the results of the poll, but also send predefined fields to a contact management database.

    Where in the YOP files – after it has already recorded the results – send the custom fields to this database? Thanks.

    https://wordpress.org/plugins/yop-poll/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author YOP

    (@yourownprogrammer)

    Hi DreamsFulfilledAgents,

    You are looking for the insert_vote_custom_field_in_database function, located in inc/yop_poll_model.php, approximately on line 2272.

    Regards,

    YOP Team

    Thread Starter DreamsFulfilledAgents

    (@dreamsfulfilledagents)

    Thank you very much for that. I found a couple of tutorials on how to do this, but none of them work. Is there a way to modify that function to automatically send those variables to http://contact-management-processing/SubmitAction.do without redirecting the user to the site, or forcing the end user to make an additional click?

    If so, would you please be kind enough to let me know, or direct me to a tutorial on how I can set this up? Thank you very much.

    Plugin Author YOP

    (@yourownprogrammer)

    Hi DreamsFulfilledAgents,

    You can use PHP’s cUrl library to send variables you need. We recommend you to set CURLOPT_RETURNTRANSFER option in order to return response from remote application and not to echo it.

    Regards,
    YOP Team!

    Thread Starter DreamsFulfilledAgents

    (@dreamsfulfilledagents)

    Thank you so much for your reply. I have not heard of that before, and was wondering if you would be kind enough to give me the url of a tutorial on how I can implement this (and even what it is)? Thank you.

    Thread Starter DreamsFulfilledAgents

    (@dreamsfulfilledagents)

    would it be easier, or even possible to have the form send the information to two urls?

    Plugin Author YOP

    (@yourownprogrammer)

    Hey DreamsFulfilledAgents,

    Here’s the tutorial you requested:

    http://www.php.net/manual/en/curl.examples.php

    Regarding your second question, you can send the information to only one url.

    Best wishes,

    YOP Team

    Thread Starter DreamsFulfilledAgents

    (@dreamsfulfilledagents)

    Thank you for the reply. I have looked through the tutorial you gave me. I have been trying all kinds of tings, and just banging my head against the wall. I have even found a number of tutorials, but can’t understand them well enough to implement it.

    I’m not seeing on them how I need to split this around the code of the poll. Do I do it like this?

    // Get cURL resource
    $curl = curl_init();
    
    //YOP POLL lines 2271-2279
    
    // Set some options
    curl_setopt_array($curl, array(
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_URL => 'http://testcURL.com',
        CURLOPT_POST => 1,
        CURLOPT_POSTFIELDS => array(
            firstName => 'First Name Value',
            lastName => 'Last Name Value',
            email => 'E-Mail Value'
        )
    ));
    // Send the request & save response to $resp
    $resp = curl_exec($curl);
    // Close request to clear up some resources
    curl_close($curl);

    Also, I don’t understand how to get the value being sent for the variable firstName to be the value the user enters into the custom field labled ‘First Name’?

    Any assistance you can provide will be greatly appreciated. Thanks again.

    Plugin Author YOP

    (@yourownprogrammer)

    Hi DreamsFulfilledAgents,

    Edit yop_poll_model.php and in register_vote() function, approximately on line 2726 add

    $custom_field_label_value= array_merge(array($custom_field_base['custom_field']=>$custom_field['custom_field_value']),$custom_field_label_value);

    (you’ll have to declare the array first).

    The cURL looks ok but in CURLOPT_POSTFIELDS you have to use the array we mentioned above.

    Regards,

    YOP Team

    Thread Starter DreamsFulfilledAgents

    (@dreamsfulfilledagents)

    Hi there,

    OK, so I’ve looked at the code, and I don’t see register_vote at line 2726, but I found it at line 2447. Is this the section I need to change?

    public function register_vote( $request ) {
    			global $current_user;
    			$poll_id   = $this->poll['id'];
    			$unique_id = $this->unique_id;
    			$location  = $request['location'];
    			if ( wp_verify_nonce( $request['yop-poll-nonce-' . $poll_id . $unique_id], 'yop_poll-' . $poll_id . $unique_id . '-user-actions' ) ){

    And, do I add $custom_field_label_value= array_merge(array($custom_field_base['custom_field']=>$custom_field['custom_field_value']),$custom_field_label_value); after line 2451 that reads:

    $location = $request['location']; or before global $current_user;

    But, if I have to declare the array first, don’t I need to do this before line 2271? Or will it still work by delcaring the array at line 2447?

    And then, I just leave the cURL function exactly the same as I have above? Or do I change the firstName => 'First Name Value', etc.?

    Thank you again for all your help. I really appreciate it.

    Plugin Author YOP

    (@yourownprogrammer)

    Hi DreamsFulfilledAgents,

    Please email us at yop.help (@] gmail.com and we will provide a .txt file that includes the code with all the modifications.

    Regards,

    YOP Team

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Also submit custom fields to contact management software.’ is closed to new replies.