This site uses cookies and similar technologies.

If you don't change browser settings, you agree to it.

I understand
60 Posts
ggl082
5 months ago
7
Topic

Hi,

   User are created by a specific tools that manage subscription plan, payment and so on...  When a new user subscribe to a plan, the tools create the user into Joomla table and manage only flag "Active" and "Activited". I need to add some additional fields into the user account regarding some parameters of application. The problem is when the tools create the user, it is not created into Seblod (no entry into cck_core table).

   I have not found any option to have an automatic user creation at Seblod level. A solution can be to create a trigger and and entry into cck_core and cck_store_item_users and cck_form_user, but if another integrated solution exist I prefer use it.

Thank you in advance for your answer.

Gérard

Get a Book for SEBLOD
638 Posts
Bucklash
5 months ago
0
Level 1

Hi

Hi, how about the other wsy round?

A button that creates a seblod user and use afterstore to update subscription db tables

Note:

I tried that nicely with Payplans but there were other 'issues' which prevented me using it with Seblod

2578 Posts
Klasadministrator
4 months ago
5
Level 1

If you cna preventYou can manually create users in seblod, the same way as any other content type (see manual).

60 Posts
ggl082
4 months ago
4
Level 2

Hi Klas,

Thank you for your answer. There are into the link some important information and answer regarding other problem than I have not yet solved. Regarding this one, I have added trigger to joomla user table that update Seblod additional user table. After many tests all work fine now, I can use the tools to manage subscription with payment plugin available for customer bank. I can communicate trigger content to help somebody who have same problem, but as these triggers update Seblod table, I prefer to have your agreement before.

Gerard

2578 Posts
Klasadministrator
4 months ago
3
Level 3

Hi,

yes, please post info how you solved it. Of course anyone is doing this on their own risk.

60 Posts
ggl082
4 months ago
2
Level 4

Hi Klas,

As I use and external tools to manage users subscription and so on. This tools create directly the user into Joomla table. Nevertheless when the user is registered, it is better to used Seblod, so SEBLOD table must be updated before. For that I have added following trigger to Joomla table:

DELIMITER //
CREATE TRIGGER `xxxxx_user_create_t` AFTER INSERT ON `xxxxx_users`


FOR EACH ROW BEGIN
INSERT INTO xxxxx_cck_core (cck, pk, pkb, storage_location, author_id, parent_id, store_id, date_time) VALUES ('user', NEW.id, 0, 'joomla_user', NEW.id,0,0,NOW());

INSERT INTO xxxxx_cck_store_item_users (id, cck) VALUES (NEW.id, 'user');

INSERT INTO xxxxx_cck_store_form_user (id, ..... ) VALUES (NEW.id, ...... ); /*Only if you use a Seblod form with additionnal fields*/
END

//
DELIMITER ;

DELIMITER //
CREATE TRIGGER `xxxxxx_user_delete_t` BEFORE DELETE ON `xxxxx_users`
FOR EACH ROW BEGIN
DELETE FROM xxxxx_cck_core where pk=OLD.id;

DELETE FROM xxxxx_cck_store_item_users where id=OLD.id;

DELETE FROM xxxxx_cck_store_form_user where id=OLD.id; /*Only if you use a Seblod form with additionnal fields*/

END
//
DELIMITER ;

Note than DELIMITER and // are used only to execute this script with PHPMyAdmin.

IMPORTANT: This solution work only if user is created by Joomla or external tools. If user must be created also manually with a Seblod Form, two entry are created into xxxxx_cck_core (One from trigger, second by Seblod). To prevent this behaviour, the following code must be added into Seblod User Creation Form with AfterStore:

<?php
//Dans le cas d'une création de user depuis une Form Seblod, détruire le doublon inséré par le trigger et Seblod

defined( '_JEXEC' ) or die;

if (config['isNew'] == 1){
// Uniquement si nouveau user
$db = JFactory::getDbo(); // Get a db connection.
$pk_user = $config['pk']; // Id user

// Vérifie si le trigger a créé un doublon (Cas d'un User créé depuis une form Seblod)
// Uniquement sur table #__cck_core, car pk n'est pas unique
$db->SetQuery("SELECT count(*) FROM `#__cck_core` WHERE pk = " . $pk_user);
$result = $db->loadResult();

if ($result>1){
// la première ligne est celle insérée par le trigger --> a détruire
$db->SetQuery("SELECT MIN(id) from `#__cck_core` WHERE pk = " . $pk_user);
$id = $db->loadResult();
$db->SetQuery("DELETE FROM `#__cck_core` WHERE id = " . $id);
$db->execute();
}
}

?>

Into the context of my WebSite, this solution work fine.

Hope can help.

40 Posts
zaliyanna
2 months ago
1
Level 5

Hello,

I have the same pb ,

I use an other component to register throught social network it's common now...

My idea is same as you but with hacking the registration component, so  I found where this component creates user and here I have to use the event onUserAfterSave to create the row in cck tables.

is there any other solution to do that without hacking?

thanks 

2578 Posts
Klasadministrator
2 months ago
0
Level 6

If you put your Seblod user creating code in a plugin it won't be hacking?

Get a Book for SEBLOD