[SOLVED - My bad!] Can't create new Joomla users when importing a csv file

GESTIO

New Member
Hi,

I need to use the listcsv plugin to "automagically" create new Joomla users after importing a csv file in table "gestio_personale".
Creation of new users using juser form plugin works well when I manually insert new records.

I edited a copy of the script "/plugins/fabrik_list/listcsv/scripts/create_client_user.php", modifying corresponding elements' name; then I selected this new script in the listcsv plugin of the list "gestio_personale".

Here is the script:
PHP:
<?php
/**
* Fabrik List CSV plugin example script
*
* @package    Joomla.Plugin
* @subpackage  Fabrik.list.listcsv
* @copyright  Copyright (C) 2005-2013 fabrikar.com - All rights reserved.
* @license    GNU/GPL http://www.gnu.org/copyleft/gpl.html
*/
 
/**
* Some example code for creating J! users when importing CSV file.
*
* Instructions:
*
* 1) Install the listcsv plugin, and add it to the List you are importing to.
*
* 2) Copy and rename this file, to whatever name you want, in the same directory,
* to avoid having your changes overwritten next time you update Fabrik.
*
* 3) Modify the REQUIRED 'changethis' options below to match your full element names.
*
* 4) Set any of the OPTIONAL options below.
*
* 5) On your List plugin settings for the List CSV plugin, select the renamed file from step 2
*
* 6) Run your CSV import.  This plugin will run once for each row being imported, and
* attempt to either create or modify a J! user accordingly. Modification occurs if username already exists
*
*/
defined('_JEXEC') or die();
 
require_once JPATH_SITE . '/plugins/fabrik_list/listcsv/scripts/csv_import_user_class.php';
 
$csv_user = new ImportCSVCreateUser;
 
/*
* REQUIRED
*
* The full Fabrik element names for the username, email, name and J! userid.
* The plugin will write the newly created J! userid to the userid element.
* These four are REQUIRED and the code will fail if they are missing or wrong.
*/
 
$csv_user->username_element = 'gestio_personale___username';
$csv_user->email_element = 'gestio_personale___email';
$csv_user->name_element = 'gestio_personale___name';
$csv_user->userid_element = 'gestio_personale___joomla_userid';
 
/*
* OPTIONAL
*
* The following are optional:
*
* password_element - if specified, plugin we will use this as the clear text password
* for creating a new user.  This value will be cleared and not saved in the table.
* If not specified, plugin will generate a random password when creating new users.
*
* first_password_element - if specified, the clear text password used to create the
* user will be stored in this field, whether it came from a specified password_element
* or was randomly generated.  Can be same as password_element if you want.
*
* user_created_element - if specified, this element will be set to a configurable value
* if a user is created.
*
* user_created_value - value to use when setting user_created_element above.
*/
 
$csv_user->password_element = '';
$csv_user->first_password_element = '';
$csv_user->user_created_element = '';
$csv_user->user_created_value = '1';
 
$listModel = $this->getModel();
$csv_user->createUser($listModel);
 
?>

When I import a csv file, records are correctly load into table, but elements "username", "name", "mail" and "userid are all empty.

Thank you for your support!

Regards

Tom


P.S.
I can't post in "Support" subforum, but I'm a Standard subscriber... Is this normal?



Environment:
  • Joomla 3.3.6
  • Fabrik 3.2 with latest GitHub Update
  • Chrome
  • Screenshoots: see attachments
 

Attachments

  • Selecting _script.png
    Selecting _script.png
    37.3 KB · Views: 236
  • Importing_csv.png
    Importing_csv.png
    24.9 KB · Views: 231
Try logging in from the site's homepage (not the forum). This should log you into the site and also fix any credential issues you might have. I tried this using your username and my master password and I could post in the standard support forum.

For your question can I confirm that the user is created with the correct data? And that the issue is that the same data is not stored in the gestio_personale list?
Could you also post a copy of the csv file you are using?
thx
 
Try logging in from the site's homepage (not the forum). This should log you into the site and also fix any credential issues you might have. I tried this using your username and my master password and I could post in the standard support forum.

Ok, solved!

For your question can I confirm that the user is created with the correct data? And that the issue is that the same data is not stored in the gestio_personale list?
Could you also post a copy of the csv file you are using?
thx


No, the issue was that the data was stored in the gestio_personale list but users were not created.

I'm sorry Rob, I understand that I was wrong...
In this table username value has to be picked from another element's value; I used a php script to manage this when creating new records, but I didn't think that form plugins are not elaborated when csv are imported, therefore I was trying to import a csv without a defined "username" column!

I edited the listcsv import script to "resolve" the issue.

Thank you for you support, Fabrik is really a wonderful tool!
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top