Add extra field to users

your function never defines a value for that field so when you check if its equal to 1 you never get true.

try this:

add_action( 'show_user_profile', 'module_user_profile_fields' );
add_action( 'edit_user_profile', 'module_user_profile_fields' );
function module_user_profile_fields( $user ) 
{ ?>
    <h3>Module Options</h3>

    <table class="form-table">
        <tr>
            <th><label for="module_activation">Module Activation</label></th>
            <td>
                <input id="module_activation" name="module_activation" type="checkbox" value="1" <?php if ( get_the_author_meta( 'module_activation', $user->ID ) == 1  ) echo ' checked="checked"'; ?> />
                <span class="description"><?php _e("Please enter your address."); ?></span>
            </td>
        </tr>
    </table>
<?php }

add_action( 'personal_options_update', 'save_module_user_profile_fields' );
add_action( 'edit_user_profile_update', 'save_module_user_profile_fields' );

function save_module_user_profile_fields( $user_id ) 
{
    if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }else{
        if(isset($_POST['module_activation']) && $_POST['module_activation'] > 0){
            update_usermeta( $user_id, 'module_activation', $_POST['module_activation'] );
        }else{
            delete_usermeta($user_id, 'module_activation');
        }
    }
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)