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

查看:16
本文介绍了编写 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天全站免登陆