Drupal 7以负载模式2编程 [英] Drupal 7 load profile2 programmatically
本文介绍了Drupal 7以负载模式2编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个profile2配置文件定义了main和customer_profile。此外,我有一个名为Customer的节点类型。
I have two profile2 profiles defined - main and customer_profile. Also, I have a node type called Customer.
创建新的Customer节点时,我想加载custom_profile表单。这个想法是同时创建一个节点和一个配置文件。
When creating a new Customer node, I would like to load the custom_profile form. The idea is to create a node and a profile simultaneously.
我知道这是一个hook_form_alter解决方案,但有人可以告诉我如何以编程方式加载配置文件,同时创建或编辑客户节点。
I know it's definately a hook_form_alter solution but can someone tell me how to programmatically load a profile while creating or editing a Customer node.
推荐答案
您可以使用这些功能加载配置文件类型和数据
You can load profile type and data by using these function
$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以负载模式2编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文