Skip to Content Skip to Menu

🕒 Save Time and Effort with CB Editor Assistant: Effortlessly create and refine content in Joomla 3, 4, & 5.
🎁 Limited Offer: Enjoy a 5-day FREE trial and save up to 30% afterward!

Triggers in Auto Actions

  • glenanPL
  • glenanPL
  • OFFLINE
  • Posts: 50
  • Thanks: 2
  • Karma: -1
7 years 11 months ago #291579 by glenanPL
Triggers in Auto Actions was created by glenanPL
Hi,
have a problem with the triggers in Auto Actions with Adsmanager. In fact, I want to fire a SQL query when a new user is registered via Adsmanager. Indeed, to post an ad, users who are not registered will be automatically registered. I tested the SQL query with the trigger "AfterUserUpdate" and "AfterUpdateUser" and it works. I tested with the trigger "AfterUserApproval" and it works.
But when I use the trigger "AfterUserRegistration" and "AfterNewUser" the query is not fired. I think that automatic registration via Adsmanager does not fire the triggers "AfterUserRegistration" and "AfterNewUser".
What do you think ?
Which triggers should I use ?
Thank you,

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48709
  • Thanks: 8319
  • Karma: 1447
7 years 11 months ago #291603 by krileon
Replied by krileon on topic Triggers in Auto Actions
I've no idea how Adsmanager is registering users in CB so I don't know what to tell you in regards to what trigger to use, sorry. You'll need to contact Adsmanager to see what triggers they're firing, but sounds like they're just creating a Joomla user then saving again using CB API and is likely why the update trigger is firing.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • glenanPL
  • glenanPL
  • OFFLINE
  • Posts: 50
  • Thanks: 2
  • Karma: -1
7 years 10 months ago #291983 by glenanPL
Replied by glenanPL on topic Triggers in Auto Actions
Hi Kyle,
Thank you for you answer. I looked to the Adsmanager code to find the function which creates the user account when an ad is posted.
This is just a data injection query in the comprofile table. (administrator/components/com_adsmanager/models/user.php)
With these information, can you tell me which triggers can be used ?
Thank you!

Code:
function saveRegistration($comprofiler) { // If user registration is not allowed, show 403 not authorized. $params = JComponentHelper::getParams('com_users'); if ($params->get('allowUserRegistration') == '0') { echo "Error: allowRegistration set to Off in Joomla."; exit(); } if (version_compare(JVERSION,'1.6.0','<')) { $authorize = JFactory::getACL(); $user = clone(JFactory::getUser()); // Initialize new usertype setting $newUsertype = $params->get( 'new_usertype' ); if (!$newUsertype) { $newUsertype = 'Registered'; } // Bind the post array to the user object $post = JRequest::get('post'); $post['username'] = $post['username']; $post['password2'] = $post['password']; if (!$user->bind($post, 'usertype' )) { JError::raiseError( 500, $user->getError()); } // Set some initial user values $user->set('id', 0); $user->set('usertype', $newUsertype); $user->set('gid', $authorize->get_group_id( '', $newUsertype, 'ARO' )); $date = JFactory::getDate(); $user->set('registerDate', $date->toMySQL()); // If user activation is turned on, we need to set the activation information $useractivation = $params->get( 'useractivation' ); if ($useractivation == '1') { jimport('joomla.user.helper'); $user->set('activation', JUtility::getHash( JUserHelper::genRandomPassword()) ); //$user->set('block', '1'); } // If there was an error with registration, set the message and display form if ( !$user->save() ) { JError::raiseWarning('', JText::_( $user->getError())); return false; } } else { // Initialise the table with JUser. $user = new JUser; $data = JRequest::get('post'); //HACK OUTROUVER //$data['username'] = $data['email']; // Prepare the data for the user object. $useractivation = $params->get('useractivation'); // Check if the user needs to activate their account. if (($useractivation == 1) || ($useractivation == 2)) { jimport('joomla.user.helper'); if (version_compare(JVERSION,'3.0.3','>=')) { $data['activation'] = JApplication::getHash(JUserHelper::genRandomPassword()); } else { $data['activation'] = JUtility::getHash(JUserHelper::genRandomPassword()); } //$data['block'] = 1; } // Get the groups the user should be added to after registration. $data['groups'] = array(); // Get the default new user group, Registered if not specified. $system = $params->get('new_usertype', 2); $data['groups'][] = $system; // Bind the data. if (!$user->bind($data)) { $this->setError(JText::sprintf('COM_USERS_REGISTRATION_BIND_FAILED', $user->getError())); return false; } // Load the users plugin group. JPluginHelper::importPlugin('user'); // Store the data. if (!$user->save()) { $this->setError(JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED', $user->getError())); return false; } } $post = JRequest::get('post'); $username = $post['username']; //HACK OUTROUVER //$username = $post['email']; $this->_db->setQuery( 'SELECT `id`' . ' FROM `#__users`' . ' WHERE username=' . $this->_db->Quote( $username )); $userid = (int)$this->_db->loadResult(); if ($comprofiler > 0) { $data = new stdClass(); $data->id = $userid; $data->user_id = $userid; $data->lastname = JRequest::getVar('name', "" ); $data->firstname = JRequest::getVar('firstname', "" ); $data->middlename = JRequest::getVar('middlename', "" ); [b] //HACK OUTROUVER[/b] /*$data->cb_civilite= JRequest::getVar('cb_civilite', "" ); $data->cb_companyname= JRequest::getVar('cb_companyname', "" ); $data->cb_siren= JRequest::getVar('cb_siren', "" ); $data->cb_tel= JRequest::getVar('cb_tel', "" ); $data->cb_profiletype = JRequest::getVar('cb_profiletype','');//professionnel,particulier */ $this->_db->setQuery("SELECT count(*) FROM #__comprofiler WHERE id = $userid"); $result = $this->_db->loadResult(); if ($result) $this->_db->updateObject('#__comprofiler', $data,'id'); else $this->_db->insertObject('#__comprofiler', $data); } return $userid; }

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48709
  • Thanks: 8319
  • Karma: 1447
7 years 10 months ago #291994 by krileon
Replied by krileon on topic Triggers in Auto Actions
That's directly inserting into the database so you won't be able to act on registrations done through Ads Manager using CB Auto Actions.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • glenanPL
  • glenanPL
  • OFFLINE
  • Posts: 50
  • Thanks: 2
  • Karma: -1
7 years 10 months ago #292070 by glenanPL
Replied by glenanPL on topic Triggers in Auto Actions
Thank you for your answer,
Is there an existing trigger that I can use or an upcoming trigger ?
Is there a trigger like "Synchronize Users" in CB -> Tools ?

Best regards

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48709
  • Thanks: 8319
  • Karma: 1447
7 years 10 months ago #292080 by krileon
Replied by krileon on topic Triggers in Auto Actions

Is there an existing trigger that I can use or an upcoming trigger ?

No, because they're not firing one.

Is there a trigger like "Synchronize Users" in CB -> Tools ?

That won't work as there's nothing to synchronize since they're inserting the user into _comprofiler already.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum