Skip to content

Instantly share code, notes, and snippets.

@thisislawatts
Created August 6, 2013 11:49
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save thisislawatts/6163831 to your computer and use it in GitHub Desktop.
WordPress Importer - When you've got a stack of users to import and there's a decent mix of one's that already exist, sorting them out is an unnecessary pain ->
jQuery('#authors li').each(function() {
var $self = jQuery(this);
var $strong = $self.find('strong');
var $select = $self.find('select');
var username = $strong.text().match(/\(([\w]*)\)/);
var matched = false;
console.log(username[1])
if (username) {
$select.find('option').each(function() {
if (jQuery(this).text() === username[1]) {
jQuery(this).attr('selected', true);
matched = true;
}
});
}
if (!matched) {
$self.find('input[type="text"]').val(username[1]);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment