Created
July 20, 2012 13:30
-
-
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/
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
<?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