user name must be generated before the user is registeredSomething like this could be possible, by changing the username input before registration process with a function like this:
public function onAfterRoute()
{
$app=JFactory::getApplication();
if(JFactory::getApplication()->input->get('task')=='registration.register' || ($app->isAdmin() && JFactory::getApplication()->input->get('option')=='com_users' && JFactory::getApplication()->input->get('layout')=='edit' && JFactory::getApplication()->input->get('id',-1)==0 ))
{
$year_file_path = JPATH_SITE . '/' . date('Y').'.txt'; /* path of file where is store last id, the name depends from the year */
if(file_exists($year_file_path)){
$last_id = file_get_contents($year_file_path); /* if file exists then get last id from year file */
}
else{
$last_id = 0; /* if file does not exists then last id is 0 */
}
$new_id = (int) $last_id + 1; /* new id = last id +1 */
file_put_contents($year_file_path, $new_id); /* save the new last id in year file*/
$new_username = 'int'.date('Y').sprintf("%04d", $new_id); /* generate username with a format like int20190023*/
/* replace username var */
$input = JFactory::getApplication()->input;
$form=$input->post->get('jform', array(), 'array');
$form['username'] = $new_username
$input->post->set('jform', $form);
JFactory::getApplication()->input->set('jform', $form);
}
}
Hello %s,\n\nThank you for registering at %s. Your account is created and must be activated before you can use it.\nTo activate the account select the following link or copy-paste it in your browser:\n%s \n\nAfter activation you may login to %s using the following username and password:\n\nUsername: %s\nPassword: %sto
Hello %s,\n\nThank you for registering at %s. Your account is created and must be activated before you can use it.\nTo activate the account select the following link or copy-paste it in your browser:\n%s
<?php
defined('_JEXEC') or die;
class PlgJsnSkeleton extends JPlugin
{
public function triggerProfileUpdate($user, &$data, $changed, $isNew)
{
if($isNew && $user->id > 0)
{
$year_file_path = JPATH_SITE . '/' . date('Y').'.txt'; /* path of file where is store last id, the name depends from the year */
if(file_exists($year_file_path)){
$last_id = file_get_contents($year_file_path); /* if file exists then get last id from year file */
}
else{
$last_id = 0; /* if file does not exists then last id is 0 */
}
$new_id = (int) $last_id + 1; /* new id = last id +1 */
file_put_contents($year_file_path, $new_id); /* save the new last id in year file*/
$new_username = 'int'.date('Y').sprintf("%04d", $new_id); /* generate username with a format like int20190023*/
/* save new username in DB */
$db = JFactory::getDbo();
$query = 'UPDATE #__users SET username = ' . $db->quote($new_username) . ' WHERE id = '. (int) $user->id;
$db->setQuery($query);
$db->execute();
}
}
}
.control-group.username-group {display:none !important;}
jQuery(document).ready(function(){jQuery('#member-registration #jform_username').val(Math.random().toString(36).substring(7))});
<?php
defined('_JEXEC') or die;
class PlgJsnSkeleton extends JPlugin
{
public function triggerProfileUpdate($user, &$data, $changed, $isNew)
{
if($isNew && $user->id > 0)
{
$new_username = 'int'.date(Y).$user->id;
$db = JFactory::getDbo();
$query = 'UPDATE #__users SET username = ' . $db->quote($new_username) . ' WHERE id = '. (int) $user->id;
$db->setQuery($query);
$db->execute();
}
}
}
Working days: Monday to Friday. The support staff is not available on weekends; in the most of cases tickets will not be answered during that time.
Reply time: Depending on the complexity of your support issue it's usually between a few minutes and 24 hours for paid members and about one week for free members. When we expect longer delays we will notify you.
Before you post: read the documentation and search the forums for an answer to your question.
When you post: include Site Details if you request a support (you can use the form below the reply in Site Details tab).
Auto Solved Question: If after a week the author of the post does not reply to a request by moderator, the question will be marked as resolved.
Language: only English
Easy Profile® is not affiliated with or endorsed by Open Source Matters or the Joomla Project. Joomla is Free Software released under the GNU/GPL License.
Our site uses non fat, delicious cookies which help us improve your user experience. You can read more about it in our Legal page.