I have properly installed the module Token, Content Profile, and activate the Content Profile Token. However when using rule, there is still nothing like "Replacement Pattern for Author Content Profile" and hence no token available for Content Profile. I'm using Content profile 6x-1.0.

CommentFileSizeAuthor
#4 select-1063234-4.patch1.85 KBjeffam
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

szeidler’s picture

Same problem here:

content_profile_tokens.module line 20 is always empty on registration. I think that the node is not created at this point of time.

$profile = content_profile_load($type_name, $object->uid);
mrfelton’s picture

Changing this line to the following resolves this issue. But, I think it may have a bit of a performance hit, since it will cause the node to be fully reloaded for every single token evaluation.

$profile = content_profile_load($type_name, $object->uid, '', TRUE);

So, my solution is to call content_profile_load($type_name, $object->uid, '', TRUE); myself just before I want to process the tokens in my custom user registration #submit handler. This causes the content profile cache to be rebuilt, and ensures that the tokens are available for use in my registration handler.

kmajzlik’s picture

Component: Rules integration » Base module
Category: support » bug

hm almost same issue here: i have custom module using
function content_profile_tokens_token_values($type, $object = NULL, $options = array())
and i have ONLY SOME of fields as tokens there. I searched why and found:
content_profile_tokens.module

  13 function content_profile_tokens_token_values($type, $object = NULL, $options = array()) {
  14   $values = array();
  15   $types = content_profile_get_types('types');
  16   switch ($type) {
  17     case 'user':
  18       foreach($types as $type_name => $type) {
  19         if (isset($object)) {
  20           $profile = content_profile_load($type_name, $object->uid);
  21         }
  22         else {
  23           global $user;
  24           $profile = content_profile_load($type_name, $user->uid);
  25         }
  26         $fields = content_types($type_name);
  27         foreach ($fields['fields'] as $field_name => $field) {
  28           if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) {
  29               $values['content-profile-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile->{$field_name}[0]['value']);
  30               $values['content-profile-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile->{$field_name}[0]['value'];
  31           }
  32         }
  33       }
  34       break;

Why that stupid IF on line #28 ? I have fields with type Integer and widget Select list. Not important why i need select list, but why somebody thought that i do not want that field as token?

jeffam’s picture

Component: Base module » Miscellaneous
Status: Active » Needs review
FileSize
1.85 KB

Just ran into this issue myself and decided to test and see what would happen if I allowed text fields using the select box widget to be used as tokens.

Seems to work just fine.

I suspect that there is a reason that only numbers and textfields were allowed to be used, but I can't really see it. As long as multiple fields are being excluded, this should just work.

So here's a patch.

Pinolo’s picture

Status: Needs review » Closed (duplicate)

Marking as duplicate of #1123030: Content Profile Token support for additional widget types, multiple value fields. There, you can find a more comprehensive approach to the issue.