Plugin Directory

Changeset 712715


Ignore:
Timestamp:
05/14/2013 05:26:29 AM (13 years ago)
Author:
Youdaman
Message:

added Custom Field

Location:
capsule-sync/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • capsule-sync/trunk/capsule-sync.php

    r706996 r712715  
    2323    register_setting( 'capsule-sync-settings-group', 'capsule_sync_role', 'validate_custom_field' );
    2424    register_setting( 'capsule-sync-settings-group', 'capsule_sync_tag', 'validate_custom_field' );
     25    register_setting( 'capsule-sync-settings-group', 'capsule_sync_customfield', 'validate_custom_field' );
    2526    register_setting( 'capsule-sync-settings-group', 'capsule_sync_first_name', 'validate_custom_field' );
    2627    register_setting( 'capsule-sync-settings-group', 'capsule_sync_last_name', 'validate_custom_field' );
     
    126127        </tr>
    127128
     129        <tr valign="top">
     130        <th scope="row">Custom Field custom field</th>
     131        <td><input type="text" name="capsule_sync_customfield" value="<?php echo get_option('capsule_sync_customfield'); ?>" placeholder="e.g. commission" /></td>
     132        </tr>
     133         
    128134    </table>
    129135   
     
    274280$api_key = get_option('capsule_sync_api_key');
    275281$tag = get_option('capsule_sync_tag');
     282$customfield = get_option('capsule_sync_customfield');
     283$customfield_value = get_user_meta($user_id, $customfield, true);
    276284
    277285if ($person_xml && $subdomain && $api_key) {
     
    306314    //POST /api/party/:party-id/tag/:tag-name
    307315
    308     if ($tag) {
     316    if ($id && $tag) {
    309317      curl_setopt($curl, CURLOPT_URL, "https://".$subdomain.".capsulecrm.com/api/party/$id/tag/$tag");
    310318      curl_setopt($curl, CURLOPT_POSTFIELDS, null);
     
    317325          return false;
    318326      }
     327
     328    }
     329
     330    if ($id && $customfield && $customfield_value) {
     331
     332      $customfield_xml =
     333      $customfield_xml = <<<EOT
     334<customFields>
     335<customField>
     336<label>$customfield</label>
     337<text>$customfield_value</text>
     338</customField>
     339</customFields>
     340EOT;
     341
     342      curl_setopt($curl, CURLOPT_URL, "https://".$subdomain.".capsulecrm.com/api/party/$id/customfields");
     343      curl_setopt($curl, CURLOPT_POSTFIELDS, $customfield_xml);
     344      curl_setopt($curl, CURLOPT_HEADER, false);
     345
     346      $output = curl_exec($curl);
     347      if ($curl_error = curl_errno($curl)) {
     348          curl_close($curl);     
     349          error_log($curl_error);
     350          return false;
     351      }
    319352    }
    320353
  • capsule-sync/trunk/readme.txt

    r707034 r712715  
    55Requires at least: 3.0
    66Tested up to: 3.5.1
    7 Stable tag: 1.0
     7Stable tag: 1.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3636== Changelog ==
    3737
     38= 1.1 =
     39*  Added Custom Field.
     40
    3841= 1.0 =
    3942* First public release.
Note: See TracChangeset for help on using the changeset viewer.