I am trying to integrate both the values from an existing custom taxonomy and custom author profile fields. I would like the values to be used as the options from which an author can select when updating/filling out her profile.
The below works – kind of. (Found in functions.php file)
It saves to the database (users table) but it the “checked” radio does not save. It also does not print properly in the profile section, and looks like this (immediately preceding the radio button) checked="checked" />
… Here is the full code
<tr>
<th><label for="sorority"><?php _e('What sorority are you in?'); ?></label></th>
<td>
<?php $sorority = get_the_author_meta( 'sorority', $user->ID ); ?>
<?php
$terms = get_terms("sorority");
$count = count($terms);
echo '<ul>';
foreach ( $terms as $term ) {
echo '<li><input type="radio" value="' . esc_attr( $term->name ) . '" name="sorority" <?php if ($sorority == "' . esc_attr( $term->name ) . '") { ?>checked="checked"<?php }?> />'.$term->name.'</li>';
}
echo "</ul>";
?>
</td>
</tr>
Any thoughts? I believe the problem is something with this line:
<?php if ($sorority == "' . esc_attr( $term->name ) . '") { ?>checked="checked"<?php }?>
Figured it out, for anyone who needs help with this I’m sure you can use with categories/tags as well (can also use with radio inputs and checked=”checked”:
Mamaduka,
Thanks for your response. No, its not a post saving thing – this creating extra user profile fields (http~/wp-admin/user-edit.php) with the values that are also “descendants” of a custom taxonomy.
See the code from my functions.php file below. This spits out the correct data but it is “broken” when it outputs to the screen (looks like this immediately preceding the radio button: checked=”checked” />Chi Omega)
Also, the radio button when SELECTED and SAVED will not save as selected, but it does store the correctly selected values into the users table database.
Any help is much appreciated.