User Taxonomy WordPress Saved Values

I have followed a tutorial on setting up a user taxonomy on the Justin Tadlock website. I made everything work but I wanted to adjust the taxonomy of a single radio selection to a selection of multiple check boxes.

// If there are any competency terms, loop them over and display the checkboxes.
if (! empty ($ terms)) {
foreach ($ terms like $ term) {?>
<input type = "checkbox" name = "competence-slug); ?> "id =" competence-slug); ?> "value ="slug); ?> " ID, "skill", $ term)); ?> />
<label for = "competence-slug); ?> ">first name; ?> 
<? php} }

I've adjusted the input type and name value, but I have not been able to check the values ​​of the checkboxes.

I did some simple tests and hard-coded values ​​in the backup section

$ term = esc_attr ($ _POST['competence-photographer'] )
$ term = esc_attr ($ _POST['competence-server-administrator'] )

And I was able to keep the values ​​if they were checked or not, so I created a foreach loop thinking that it would loop between all the taxonomy terms, but I have to do something wrong because I can not accept it to save the values.

function save_user_competence_terms ($ user_id) {

$ tax = get_taxonomy (& # 39; competence);

if (! current_user_can (& # 39; edit_user & # 39 ;, $ userid) && current_user_can ($ tax-> cap-> assign_terms))
returns false;

$ terms = get_terms ("competence", array ("hide_empty" => false));

if (! empty ($ terms)) {

foreach ($ terms like $ term) {
$ term = esc_attr ($ _POST[$term->slug] )

wp_set_object_terms ($ user_id, array ($ term), & # 39; competence & # 39 ;, false);

clean_object_term_cache ($ user_id, & # 39; competence & # 39;);
}
}
}

I think the method with which I approach this question is correct, but I miss something that does not allow foreach to read the conditions to check the checked boxes. Any idea would be appreciated.