编写Joomla桥 - 用户插件 [英] Writing Joomla bridge - User plugin

查看:154
本文介绍了编写Joomla桥 - 用户插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个Joomla插件来连接到数据库中的用户表(单向)。

I want to write a Joomla plugin to connect to user tables in database (one way).

因此,在新用户注册时,用户将被复制和存储在第二个表(其他脚本)。这是主要目标。

So on new user registration, user will be duplicated and stored also in second table (other script). This is main goal. Things like updating on password change/delete etc. can be left until later.

任何想法,我可以找到信息,帮助我为Joomla 1.6编写一个这样的插件?
我可以获取用户注册数据等?

Any ideas where I can find information helping me to write a plugin like this for Joomla 1.6? Where I can get user registration data etc?

推荐答案

我写了一个Joomla 1.6的插件,注册用户的ID并将其放入另一个表中。如果删除用户帐户,它还会从辅助表中删除用户信息。这应该让你去,看看我的代码下面:

I have written a plugin for Joomla 1.6 that takes the new registered user's id and puts it into another table. It also deletes the user info from the secondary table if the user account is deleted. This should get you going, have a look at my code below:

这是一个插件叫:plg_foo_user

This is for a plugin called: plg_foo_user

foouser.php

<?php

defined('_JEXEC') or die();
jimport('joomla.plugin.plugin');

class plgUserFooUser extends JPlugin
{

  function onUserAfterSave( $user, $isnew, $success, $msg ) {
    //JError::raiseWarning(100, 'here1');
    if ($isnew && $success) {
      $db = &JFactory::getDBO();
      $db->setQuery( 'INSERT INTO #__foo_users (user_id) VALUES ('.$user['id'].')' );
      $db->query();
    }
  }

  function onUserAfterDelete( $user, $success, $msg ) {
    //JError::raiseWarning(100, 'here2');
    $db = &JFactory::getDBO();
    if ($success) {
      $db->setQuery( 'DELETE FROM #__foo_users WHERE user_id ='.$user['id'] );
      $db->query();
      return true;
    }
  }

}

?>

foouser.xml

<?xml version="1.0" encoding="utf-8"?>
<extension 
  version="1.6"
  type="plugin"
  group="user">
  <name>Foo User</name>
  <author>Martin Rose</author>
  <creationDate>January 2011</creationDate>
  <copyright>(C) 2011 Open Source Matters. All rights reserved.</copyright>
  <license>GNU/GPL</license>
  <authorEmail></authorEmail>
  <authorUrl></authorUrl>
  <version>1.0</version>
  <description>Making foo happen</description>

  <files>
    <filename plugin="foouser">foouser.php</filename>
    <filename>index.html</filename>
  </files>

</extension>

这篇关于编写Joomla桥 - 用户插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆