Configure > Appearance > Edit Profile Fields: Can't delete the first field created

I am running on elgg 2.3.0. Is there a reason why the first field can't be deleted? This fields starts with id 0. This doesn't happen to the fields created after the first field though. The only way to delete the field is if you click reset but the rest of the fields will be deleted as well. 

https://github.com/Elgg/Elgg/blob/2.3/actions/profile/fields/delete.php#L18 

 

  • I finally figured out. I kept on going on circles why the following statement was never true when deleting the first field, which is id=0. 

    if ($id &&

            unset_config("admin_defined_profile_$id") &&

            unset_config("admin_defined_profile_type_$id") &&

            elgg_save_config('profile_custom_fields', $fieldlist)) {

     

            system_message(elgg_echo('profile:editdefault:delete:success'));

    } else {

            register_error(elgg_echo('profile:editdefault:delete:fail'));

    }



    Evaluating id for value zero is not evaluating as true but false or empty, in order to fix this it should be isset($id)

    Now this brings up the question of whether this is a bug or was written like this on purpose not to allow users to delete the first field created.

  • Sounds like a bug, please report on github

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking