Update user meta through a front end form

There are 3 main issues in your code:

  1. I see you’re using current_user_id() which does not exist in WordPress, so I believe that should be get_current_user_id().

  2. Your update_basic_user_meta() function basically would work in updating the user’s metadata, but you need to check whether the POST data (gender and specialty) are actually set before proceeding to update the metadata, and that the GET data named update_basic_user_meta is also set, which means the form was submitted.

    However, if I were you, I would use a nonce field than a simple GET query.

  3. You need to highlight the current selection for the “Gender” and “Specialty” options, so that users know what have they selected and whether it was actually saved. So,

    • For the “Gender” option (which uses select menu), you can use selected().

    • For the “Specialty” option (which uses radio buttons), you can use checked().

And despite add_filter() works, init is an action hook, so you should use add_action():

add_action( 'init', 'update_basic_user_meta' );   // use this
//add_filter( 'init', 'update_basic_user_meta' ); // not this

Sample snippets that would make your form works as expected

  1. Highlight the current selection for the “Gender” option:

    <?php $gender = get_user_meta( get_current_user_id(), 'gender', true ); ?>
    <select name="gender">
        <option value="male"<?php selected( 'male', $gender ); ?>><?php _e( 'Male', 'text-domain' ); ?></option>
        <option value="female"<?php selected( 'female', $gender ); ?>><?php _e( 'Female', 'text-domain' ); ?></option>
    </select>
    
  2. Highlight the current selection for the “Specialty” option:

    <?php $specialty = get_user_meta( get_current_user_id(), 'specialty', true ); ?>
    <div>
        <label><input type="radio" name="specialty" value="0"<?php checked( '0', $specialty ); ?>> <?php _e( 'Read', 'text-domain' ); ?></label><br>
        <label><input type="radio" name="specialty" value="1"<?php checked( '1', $specialty ); ?>> <?php _e( 'Write', 'text-domain' ); ?></label><br>
        <label><input type="radio" name="specialty" value="2"<?php checked( '2', $specialty ); ?>> <?php _e( 'Translate', 'text-domain' ); ?></label>
    </div>
    
  3. Function to update the user’s metadata:

    function update_basic_user_meta() {
        if ( ! empty( $_GET['update_basic_user_meta'] )    &&
            isset( $_POST['gender'], $_POST['specialty'] ) &&
            $user_id = get_current_user_id()
        ) {
            update_user_meta( $user_id, 'gender',    sanitize_text_field( $_POST['gender'] ) );
            update_user_meta( $user_id, 'specialty', sanitize_text_field( $_POST['specialty'] ) );
    
            if ( ! empty( $_POST['redirect_to'] ) ) {
                wp_redirect( $_POST['redirect_to'] );
                exit;
            }
        }
    }