简体   繁体   English

注册时使用CodeIgniter Tank Auth进行用户文件夹命名

[英]CodeIgniter Tank Auth make user folder with him name upon registration

I found some similar question 1 year ago: Codeigniter Tank Auth add folder upon registration ... but not with username included. 我在1年前发现了一些类似的问题: Codeigniter Tank Auth注册时添加了文件夹 ...但未包含用户名。 I tried to add username (of the registered person in that moment) in module, function create_user.This function create new folder with $user_id and _ like: 1_ but without username of the registered person. 我试图在模块create_user。模块中添加(当时的注册人的)用户名。此函数创建带有$user_id_新文件夹,如: 1_但没有注册人的用户名。 I tried to include data $username from $data array, but hoplesss... 我试图从$data数组中包含数据$username ,但是没钱...

if($this->db->insert($this->table_name, $data)) { 
$user_id = $this->db->insert_id();
$name = $username;

    if(!is_dir(FCPATH."./uploads/".$user_id."_".$name)){
        mkdir(FCPATH."./uploads/".$user_id."_".$name , 0777);
    }

I know that $data array has username on 1. position for DB write purpose. 我知道$data数组在1.位置具有用户名以用于数据库写入。 I tried this possiblity: $name = $username; $name = $data[0]; 我尝试过这种可能性: $name = $username; $name = $data[0]; $name = $username; $name = $data[0]; I found that the library, Tank_auth.php has function get_username() . 我发现Tank_auth.php库具有函数get_username() It is for later purpose when the new user will log in... How can I get username from $data or DB, table users, cell username ? 新用户登录时将用于以后的用途...如何从$data或DB,表用户,单元用户名中获取用户名?

Try 尝试

$name = $data['username'];

in your code to get the name of the user. 在您的代码中获取用户名。

From CodeIgniter Active Record manual , $data is an associative array which will have table field names as keys. CodeIgniter Active Record手册中$data是一个关联数组,它将表字段名称作为键。

From Tank Auth it is clear that users table contains a field with the name username to store the user's name. Tank Auth中 ,很明显, users表包含一个名称为username的字段,用于存储用户名。

Let me know if this helps. 让我知道是否有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM