I am trying to add a new field to my user edit page but I get this error
Notice: Object of class WP_User could not be converted to int in C:\xampp\htdocs\wordpress\wp-includes\capabilities.php on line 49
Here is the code I use for the functions,
static function my_extra_user_fields( $user_id ) {
echo $user_id->ID;
$user_meta = get_user_meta($user_id);
if (!empty ($user_meta['_is_post_agent'][0])) {
$check_true = $user_meta['_is_post_agent'][0];
}
else {
$check_true="false";
}
?>
<h3>Agent Author</h3>
<table class="form-table">
<tr>
<th><label for="agent_author">Agent Author</label></th>
<td>
<input type="checkbox" name="agent_author" value="is_author_agent" <?php if($check_true == 'true') echo 'checked="checked"';?> >
</td>
</tr>
</table>
<?php }
static function save_my_extra_user_fields( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) ) {
return false;
}else{
if(isset($_POST['agent_author']) && $_POST['agent_author'] == true) {
update_user_meta( $user_id, '_is_post_agent', 'true');
}
elseif(isset($_POST['agent_author']) && $_POST['agent_author'] == false) {
update_user_meta( $user_id, '_is_post_agent', 'false');
}
}
}
I would appreciate any help as to what I am doing wrong here!