drupal-7 - Drupal 7 以编程方式加载配置文件2

标签 drupal-7 profile hook-form-alter

我定义了两个 profile2 配置文件 - main 和 customer_profile。另外,我有一个名为 Customer 的节点类型。

创建新的客户节点时,我想加载custom_profile表单。这个想法是同时创建一个节点和一个配置文件。

我知道这绝对是一个 hook_form_alter 解决方案,但有人可以告诉我如何在创建或编辑客户节点时以编程方式加载配置文件。

最佳答案

您可以使用这些函数加载配置文件类型和数据

$types = profile2_get_types();
profile2_load_by_user($account, $type_name = NULL)

例如:

$types = profile2_get_types();
    if (!empty($types)) {
        foreach ($types as $type) {
            $profile = profile2_load_by_user($uid, $type->type);
        }
    }

关于drupal-7 - Drupal 7 以编程方式加载配置文件2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9548116/

相关文章:

上传到 pantheon 服务器时 .htaccess 在 drupal 7 上不起作用

drupal - 为什么我不能将字段移动到 Drupal 表单中的字段集中 - 无法获取当前值

mapping - 简单Injector注册IMappingEngine(AutoMapper)

validation - Drupal 7 - 尝试向所有节点编辑表单添加自定义验证

php - 在 drupal 中使用 hook_form_alter 设置 webform 组件值

html - 根据图像高度自动调整表格高度?

drupal 7 View 不显示任何内容

drupal - 添加一个类到 "body"

Android:检索我自己的联系信息,例如显示名称、电话号码、电子邮件地址和其他个人数据

Python 跟踪和分析