I'm importing users from a CSV and want to send a value to CAS username, but the Feeds module doesn't provide a map to this field. Are there plans to integrate with Feeds, or has anyone attempted this?

Comments

node9’s picture

Status: Active » Closed (fixed)

Solved.

bfroehle’s picture

Maybe you'd like to post the solution you found so that others could use it?

node9’s picture

Sure ... There are probably many ways to accomplish the same thing. It turned out to be more of a Feeds solution than a CAS one. I ended up exporting the Feed into a custom module and exposing the form with:

function my_custom_hook_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {
  if ($entity_type == 'user') {
    $targets['cas_name'] = array(
      'name' => t('CAS User name'),
      'description' => t('A custom field to import user names into CAS.'),
    );
  }
}

Then I mapped the values with:

...

$feeds_importer->config = array(
...

  10 => array(
    'source' => 'CAS Username',
    'target' => 'cas_name',
    'unique' => FALSE,
  ),
...

);

bfroehle’s picture

Fantastic. Hopefully anybody else who needs this in the future can use this issue as a starting point! :)

Webbeh’s picture

For future reference, I've rolled this into a very small module that should work for this based on #3

https://github.com/EricScottSembrat/feeds_user_cas_field

Works with CAS and Feeds.

Someone also proposed that if your CAS usernames == Drupal usernames, that CAS would associate itself with the local Drupal account on first CAS login. I haven't been able to test that, however.

flocondetoile’s picture

Issue summary: View changes

Hello @webbeh,

I've tried your little module and it works fine...But...I don't understand how it works.

Where is your callback function you have defined in the hook_feeds_processor_targets_alter ?
'callback' => 'user_importer_with_cas_set_target', // See 2)

Can you enlighten me ?

phl3tch’s picture

You're right; the callback specified doesn't exist. It works though, because the FeedsProcessor plugin has a default callback, which does exactly the same thing.

timwhelanatl’s picture

The module doesn't exist any more - bummer. So here is a Down and Dirty way to handle it (Back-up first!!!) -

INSERT INTO cas_user (uid, cas_name)
SELECT u.uid AS uid, u.name as cas_name
FROM users u
WHERE uid <> 0 AND NOT EXISTS (SELECT cas_name FROM cas_user c WHERE c.cas_name = u.name);
emerham’s picture

Found a fork? of the original
Forked Module