I addded a custom field in mdl_user in SQL, I want to show this custom field in the frontend, in profile edit page

huangapple go评论46阅读模式
英文:

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"的自定义字段,我只想在个人资料编辑页面中的可选部分显示它。

在mdl_user中添加的自定义字段

我想显示自定义字段的部分

有谁知道我应该在哪个.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

enter image description here

答案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.

huangapple
  • 本文由 发表于 2023年2月18日 08:40:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/75490429.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定