diff --git a/acf-export.php b/acf-export.php
new file mode 100644
index 0000000..34ee7a7
--- /dev/null
+++ b/acf-export.php
@@ -0,0 +1,190 @@
+ 'acf_person',
+ 'title' => 'Person',
+ 'fields' => array (
+ array (
+ 'key' => 'field_55a6595eba964',
+ 'label' => 'First Name',
+ 'name' => 'first_name',
+ 'type' => 'text',
+ 'required' => 1,
+ 'default_value' => '',
+ 'placeholder' => '',
+ 'prepend' => '',
+ 'append' => '',
+ 'formatting' => 'html',
+ 'maxlength' => '',
+ ),
+ array (
+ 'key' => 'field_55a6596c4a44d',
+ 'label' => 'Middle Name',
+ 'name' => 'middle_name',
+ 'type' => 'text',
+ 'default_value' => '',
+ 'placeholder' => '',
+ 'prepend' => '',
+ 'append' => '',
+ 'formatting' => 'html',
+ 'maxlength' => '',
+ ),
+ array (
+ 'key' => 'field_55a65973063d2',
+ 'label' => 'Last Name',
+ 'name' => 'last_name',
+ 'type' => 'text',
+ 'required' => 1,
+ 'default_value' => '',
+ 'placeholder' => '',
+ 'prepend' => '',
+ 'append' => '',
+ 'formatting' => 'html',
+ 'maxlength' => '',
+ ),
+ array (
+ 'key' => 'field_55a65979063d3',
+ 'label' => 'Title',
+ 'name' => 'title',
+ 'type' => 'text',
+ 'default_value' => '',
+ 'placeholder' => '',
+ 'prepend' => '',
+ 'append' => '',
+ 'formatting' => 'html',
+ 'maxlength' => '',
+ ),
+ array (
+ 'key' => 'field_55a659a4063d4',
+ 'label' => 'About',
+ 'name' => 'about',
+ 'type' => 'wysiwyg',
+ 'default_value' => '',
+ 'toolbar' => 'full',
+ 'media_upload' => 'yes',
+ ),
+ array (
+ 'key' => 'field_55a659aa063d5',
+ 'label' => 'File',
+ 'name' => 'file',
+ 'type' => 'file',
+ 'save_format' => 'object',
+ 'library' => 'all',
+ ),
+ array (
+ 'key' => 'field_55a659b1063d6',
+ 'label' => 'Email',
+ 'name' => 'email',
+ 'type' => 'email',
+ 'default_value' => '',
+ 'placeholder' => '',
+ 'prepend' => '',
+ 'append' => '',
+ ),
+ array (
+ 'key' => 'field_55a659c4063d7',
+ 'label' => 'Phone',
+ 'name' => 'phone',
+ 'type' => 'text',
+ 'default_value' => '',
+ 'placeholder' => '',
+ 'prepend' => '',
+ 'append' => '',
+ 'formatting' => 'html',
+ 'maxlength' => '',
+ ),
+ array (
+ 'key' => 'field_55a659ca063d8',
+ 'label' => 'Phone (alternate)',
+ 'name' => 'phone_(alternate)',
+ 'type' => 'text',
+ 'default_value' => '',
+ 'placeholder' => '',
+ 'prepend' => '',
+ 'append' => '',
+ 'formatting' => 'html',
+ 'maxlength' => '',
+ ),
+ array (
+ 'key' => 'field_55a659d2063d9',
+ 'label' => 'Fax',
+ 'name' => 'fax',
+ 'type' => 'text',
+ 'default_value' => '',
+ 'placeholder' => '',
+ 'prepend' => '',
+ 'append' => '',
+ 'formatting' => 'html',
+ 'maxlength' => '',
+ ),
+ array (
+ 'key' => 'field_55a659de063da',
+ 'label' => 'Mailing Address',
+ 'name' => 'mailing_address',
+ 'type' => 'text',
+ 'default_value' => '',
+ 'placeholder' => '',
+ 'prepend' => '',
+ 'append' => '',
+ 'formatting' => 'html',
+ 'maxlength' => '',
+ ),
+ array (
+ 'key' => 'field_55a659ee063db',
+ 'label' => 'Office Location',
+ 'name' => 'office_location',
+ 'type' => 'text',
+ 'default_value' => '',
+ 'placeholder' => '',
+ 'prepend' => '',
+ 'append' => '',
+ 'formatting' => 'html',
+ 'maxlength' => '',
+ ),
+ array (
+ 'key' => 'field_55a659f7063dc',
+ 'label' => 'Office Hours',
+ 'name' => 'office_hours',
+ 'type' => 'text',
+ 'default_value' => '',
+ 'placeholder' => '',
+ 'prepend' => '',
+ 'append' => '',
+ 'formatting' => 'html',
+ 'maxlength' => '',
+ ),
+ array (
+ 'key' => 'field_55a659ff063dd',
+ 'label' => 'Courses',
+ 'name' => 'courses',
+ 'type' => 'text',
+ 'default_value' => '',
+ 'placeholder' => '',
+ 'prepend' => '',
+ 'append' => '',
+ 'formatting' => 'html',
+ 'maxlength' => '',
+ ),
+ ),
+ 'location' => array (
+ array (
+ array (
+ 'param' => 'post_type',
+ 'operator' => '==',
+ 'value' => 'person',
+ 'order_no' => 0,
+ 'group_no' => 0,
+ ),
+ ),
+ ),
+ 'options' => array (
+ 'position' => 'normal',
+ 'layout' => 'no_box',
+ 'hide_on_screen' => array (
+ ),
+ ),
+ 'menu_order' => 0,
+ ));
+}
+?>
\ No newline at end of file
diff --git a/uc-people.js b/uc-people.js
index 8315df9..3af157d 100644
--- a/uc-people.js
+++ b/uc-people.js
@@ -1,13 +1,35 @@
jQuery(document).ready(function($){
- if( $('#acf-field-netid_lookup').length ){
- $('#acf-field-netid_lookup').keyup(function(e){
- if( e.target.value.length == 8 ){
- var netidQuery = e.target.value;
- console.log( netidQuery );
- /**
- * Ajax lookup with netidQuery
- */
+ if( $('#uc_people_netid_lookup').length ){
+ $('#uc_people_netid_search').click(function(ev){
+ ev.preventDefault();
+
+ var query = $('#uc_people_netid_lookup').val();
+ if( query.length == 8 && query.match(/[a-z]{3}[0-9]{5}/) ){
+ $.ajax({
+ url: ajax_object.ajax_url,
+ data: { 'action': 'uc_netid_lookup', 'netid': query },
+ success: function(response){
+ if( !isEmpty(response) ){
+ var fields = ['first_name', 'last_name', 'phone', 'email'];
+ fields.forEach(function(el,i,a){
+ if( response.hasOwnProperty(el) ){
+ $('#acf-field-'+el).val( response[el] );
+ }
+ });
+ }
+ },
+ dataType: 'json'
+ });
}
});
}
-});
\ No newline at end of file
+});
+
+function isEmpty( object ){
+ for( var key in object ){
+ if( Object.prototype.hasOwnProperty.call(object,key) ){
+ return false;
+ }
+ }
+ return true;
+}
\ No newline at end of file
diff --git a/uc-people.php b/uc-people.php
index 916391e..9f05b49 100644
--- a/uc-people.php
+++ b/uc-people.php
@@ -11,6 +11,7 @@
die;
}
include 'acf-export.php';
+require_once(WP_CONTENT_DIR . '/ldap.php');
function create_custom_custom_post_type(){
$labels = array(
@@ -181,9 +182,32 @@ function uc_people_settings_page(){
';
+ echo '';
+ echo '';
+ echo '';
+}
+
function uc_acf_admin_enqueue_scripts(){
wp_enqueue_script( 'ucpeoplejs', plugin_dir_url(__FILE__).'/uc-people.js', array('jquery'), '1.0' );
}
add_action('acf/input/admin_enqueue_scripts', 'uc_acf_admin_enqueue_scripts');
+
+add_action( 'wp_ajax_uc_netid_lookup', 'uc_netid_lookup_callback' );
+function uc_netid_lookup_callback(){
+ $query = $_GET['netid'];
+
+ $userInfo = netid_lookup($query);
+
+ echo wp_json_encode($userInfo);
+
+ wp_die();
+}
+
?>