This repository has been archived by the owner. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fills following fields; first/last name, email address, phone number
- Loading branch information
Salman Z Kaleem
committed
Jul 15, 2015
1 parent
ae0739a
commit 6386530
Showing
3 changed files
with
245 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
<?php | ||
if(function_exists("register_field_group")) | ||
{ | ||
register_field_group(array ( | ||
'id' => '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, | ||
)); | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' | ||
}); | ||
} | ||
}); | ||
} | ||
}); | ||
}); | ||
|
||
function isEmpty( object ){ | ||
for( var key in object ){ | ||
if( Object.prototype.hasOwnProperty.call(object,key) ){ | ||
return false; | ||
} | ||
} | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters