英文:
I addded a custom field in mdl_user in SQL, I want to show this custom field in the frontend, in profile edit page
问题
我使用的是Moodle 3.8版本,我添加了一个名为"razon_social"的自定义字段,我只想在个人资料编辑页面中的可选部分显示它。
有谁知道我应该在哪个.php文件中调用我的自定义字段吗?
非常感谢您的时间。
我想要做到这一点,我使用的是Moodle 3.8版本。
英文:
I am using Moodle 3.8, I added a custom field called razon_social, I just want to show it in the profile edit page, in the optional section.
Custom field added in mdl_user
Section where I want to show my custom field
Does anyone know in which file in .php, do I have to call my custom field?
Thank you very much for your time
I want to do this, I have Moodle 3.8
答案1
得分: 0
将自定义字段添加到mdl_user表(或任何其他核心表)是一个非常糟糕的主意。它可能与核心代码产生各种冲突(特别是对于Moodle使用“持久”类的表,但在其他情况下也可能出现问题)。
幸运的是,Moodle已经内建了一个自定义用户字段系统(使用表mdl_user_info_field和mdl_user_info_data),通过这种方式定义的字段会自动显示在用户个人资料页面上(除非你将它们标记为隐藏)。
编写一个脚本将从你创建的mdl_user字段中的数据转移到自定义用户字段应该相当容易。之后,你可以删除你添加的额外字段。
英文:
Adding a custom field to the mdl_user table (or any other core table) is a really bad idea. There are all sorts of ways it can conflict with the core code (particularly for tables which Moodle uses with "persistent" classes, but still a problem in other situations).
Thankfully, Moodle already has a build in custom user field system (using the tables mdl_user_info_field and mdl_user_info_data) and fields defined this way automatically appear on the user profile page (unless you mark them as hidden).
It should be fairly easy to write a script that will transfer the data from the mdl_user field you created, into a custom user field. After that, you can drop the extra field you added.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论