Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8177181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:26:46+00:00 2026-06-06T23:26:46+00:00

I use Codeigniter framework + Tank_Auth registiration library. They work great but I just

  • 0

I use Codeigniter framework + Tank_Auth registiration library. They work great but I just need to change register form a bit.

I want to generate username from email address instead of getting it from registeration form. I added a simple function to libraries/Tank_auth.php file. Here is my username generator function:

function _create_username_from_email($email)
{
$user = strstr($email, '@', true); // As of PHP 5.3.0
return $user;
}
  1. Please let me know where I need to run my function and write it to database.

  2. I will also need to remove username field from register form. So I need how I can pass form validation for username field in my controller.

I will be really happy if any of you can help me about these problem.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:26:47+00:00Added an answer on June 6, 2026 at 11:26 pm

    At line 121 in application/models/tank_auth/users you have:

    /**
     * Create new user record
     *
     * @param   array
     * @param   bool
     * @return  array
     */
    function create_user($data, $activated = TRUE)
    {
        $data['created'] = date('Y-m-d H:i:s');
        $data['activated'] = $activated ? 1 : 0;
    
        if ($this->db->insert($this->table_name, $data)) {
            $user_id = $this->db->insert_id();
            if ($activated) $this->create_profile($user_id);
            return array('user_id' => $user_id);
        }
        return NULL;
    }
    

    Just before the if ($this->db->insert($this->table_name, $data)) { insert:

    $data['username'] = strstr($data['email'], '@', true);
    

    P.S.
    I hope you understand it, but just in case – if you have two or more users with same email’s username part like john@hotmail.com and john@gmail.com they both will have the same username, which may lead to unexpected behavior.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am learning to use the CodeIgniter framework. I am coming form a world
I'm going to use Codeigniter's session data for my login system, but first I
should i use Classname() or __construct() as constructor in CodeIgniter? both work, which should
Is it possible to use CodeIgniter framework in commercial project and distribute it ?
When i do a redirect, no errors are shown. I use codeigniter framework and
I use codeigniter as my framework and in the top of my controllers I
I use CodeIgniter as my web application framework. I used a simple Try/Catch and
I am using the CodeIgniter framework to work on my latest website. In my
I am newbie. I have Windows XP and use the CodeIgniter framework. I wanted
When I use Class Hello extends CI_Controller in the CodeIgniter framework, everything runs fine.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.