Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codearachnid/3150723 to your computer and use it in GitHub Desktop.
Save codearachnid/3150723 to your computer and use it in GitHub Desktop.
An update for allowing checkbox values to be saved for http://wordpress.org/extend/plugins/user-taxonomies/
<?php
/**
* Save the custom user taxonomies when saving a users profile
*
* @param Integer $user_id - The ID of the user to update
*/
public function save_profile($user_id) {
foreach(self::$taxonomies as $key => $taxonomy) {
// Check the current user can edit this user and assign terms for this taxonomy
if(!current_user_can('edit_user', $user_id) && current_user_can($taxonomy->cap->assign_terms)) return false;
// Save the data
$user_terms = ! is_array($_POST[$key]) ? array($_POST[$key]) : $_POST[$key];
wp_set_object_terms($user_id, $user_terms, $key, false);
clean_object_term_cache($user_id, $key);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment