My plug-in adds a username generator button under the username field on registration.
Basically my plug-in just outputs this jQuery
[code:1]
$('#username').after('<br><input type="button" id="generator" value="Generate Username"/>');
$('#generator').click(function(){
$.post("/home/components/com_comprofiler/plugin/user/plug_registration2/ajax.php",{ajax : "getUsername"}, function(data){
$('#username').val(data);
});
[/code:1]
Now that seems to work, but I always get "Direct Access to this location is not allowed" or errors like $mainframe doesnt exist or could not import some cb class.
Ajax.php
[code:1]
// Security
if (!isset($_POST) && isset($_POST) == 'getIDKey') {
die('Direct Access to this location is not allowed.');
}
// Set flag that this is a parent file
define('_VALID_MOS', 1);
/* ## Emulating Joomla environment */
require_once( '../../../../../configuration.php' );
/*
* Try Include CB Framework
*/
global $_CB_framework, $mainframe;
if (defined('JPATH_ADMINISTRATOR')) {
if (!file_exists(JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php')) {
echo 'CB not installed!';
return;
}
include_once( JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php' );
} else {
if (!file_exists($mainframe->getCfg('absolute_path') . '/administrator/components/com_comprofiler/plugin.foundation.php')) {
echo 'CB not installed!';
return;
}