Skip to Content Skip to Menu

Plugin on onAfterUserStore

  • eirikop
  • eirikop
  • OFFLINE
  • Posts: 5
  • Thanks: 0
  • Karma: 0
15 years 2 months ago #107845 by eirikop
Plugin on onAfterUserStore was created by eirikop
I'm wirtinga a plugin to update a table (the #_vm_user_info).
I was thinking about to take the info from CB (#_comprofiler) and have the following code

[code:1]
function onAfterStoreUser($user, $isnew, $succes, $msg)
{
global $mainframe;
$db =& JFactory::getDBO();

$userId = $user;

$queryGetInfo = "SELECT firstname, lastname, cb_leveringadr, cb_postno, cb_area FROM jos_comprofiler WHERE user_id=$userId";

$db->setQuery($queryGetInfo);
$row = $db->loadObjectList();

$queryPostInfo = "UPDATE jos_vm_user_info SET first_name= '$firstName', last_name= '$lastName', address_1= '$adr', zip = '$zip', city = '$area' WHERE user_id='$userId'";
$db->setQuery($queryPostInfo);
$db->query();
}
[/code:1]

The problem is that the data becomes wrong in the vm_user_info table.

I think the update of #_comprofiler happens after the pluging is trigged, which gives a problem here..

Any comments?

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

  • ckayfish
  • ckayfish
  • OFFLINE
  • Posts: 34
  • Thanks: 1
  • Karma: 44
15 years 2 months ago #107999 by ckayfish
Replied by ckayfish on topic Re:Plugin on onAfterUserStore
In your second, "postinfo" querey, what is $firstName, lastName etc?

I'm fairly new to php development and have only just looked at this, but should these not be $row->firstName etc?

As for the order of execution, I'm not sure how to control the order of CB functions & Joomla plugins. Have you considered writing it as a CB plugin using the CB trigger "onAfterUserUpdate" and place this at the bottom of the plugins.

Post edited by: ckayfish, at: 2009/08/13 21:12

Tips for understanding and solving your issue - Props to Krileon for creating this.
My Opensource CB Plugins: Mutual Connections and MYCB Cookie available here

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

  • eirikop
  • eirikop
  • OFFLINE
  • Posts: 5
  • Thanks: 0
  • Karma: 0
15 years 2 months ago #108000 by eirikop
Replied by eirikop on topic Re:Plugin on onAfterUserStore
I'm sorry, but I'm cut some of the code away..

The variables are i.e $firstName = $row[0]->first_name and so on..

I should probably use a CB plugin, do you know where I can find a simple tutorial or code example? I guess the comprofiler-table is updated before onAfterUserUpdate if it is something called that in CB... Which should solve my problem... :)

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

  • eirikop
  • eirikop
  • OFFLINE
  • Posts: 5
  • Thanks: 0
  • Karma: 0
15 years 2 months ago #108332 by eirikop
Replied by eirikop on topic Re:Plugin on onAfterUserStore
Dump..

anyone?

How can I "install" the plugin such that it will be run correctly?

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

  • ckayfish
  • ckayfish
  • OFFLINE
  • Posts: 34
  • Thanks: 1
  • Karma: 44
15 years 2 months ago #108334 by ckayfish
Replied by ckayfish on topic Re:Plugin on onAfterUserStore
The HelloWorld plugin "tutorials", as well as the API document, can be found here www.joomlapolis.com/component/option,com_docman/task,cat_view/gid,50/Itemid,36/

Krileon's site www.allmysocials.com has some good tutorials and API descriptions as well.

Tips for understanding and solving your issue - Props to Krileon for creating this.
My Opensource CB Plugins: Mutual Connections and MYCB Cookie available here

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

Moderators: beatnantkrileon
Powered by Kunena Forum