$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>plugins - Creating a user's own folder on user registration|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

plugins - Creating a user's own folder on user registration

matteradmin10PV0评论

I need a plugin or some guidence on creating a user's own folder on user registation.

For example...A user clicks on Register and registers ... I need wordpress to create a directory which would be linked with this user.

The reason I want to do this is because I am going to work on building a dashboard where a wordpress template will display the contents of this user's own directory.

Let me explain further step by step: (Note: "Not Req" means I don't need help with this step)

  1. User Registers and wordpress creates a directory called the same as the username.
  2. User uploads images to that specific directory via ftp or upload - "Not Req"
  3. I create a template that would display the content of the directory / sub (images) in some kind of tree format.

Right now, what I need to do is step 1.

Hope this helps.

I need a plugin or some guidence on creating a user's own folder on user registation.

For example...A user clicks on Register and registers ... I need wordpress to create a directory which would be linked with this user.

The reason I want to do this is because I am going to work on building a dashboard where a wordpress template will display the contents of this user's own directory.

Let me explain further step by step: (Note: "Not Req" means I don't need help with this step)

  1. User Registers and wordpress creates a directory called the same as the username.
  2. User uploads images to that specific directory via ftp or upload - "Not Req"
  3. I create a template that would display the content of the directory / sub (images) in some kind of tree format.

Right now, what I need to do is step 1.

Hope this helps.

Share Improve this question edited May 3, 2012 at 21:12 user159500 asked May 3, 2012 at 20:47 user159500user159500 1812 gold badges3 silver badges8 bronze badges 2
  • 1 Do you mean an upload directory? Besides that WordPress works with virtual paths only, there are no dedicated directories for anything. – fuxia Commented May 3, 2012 at 20:55
  • Give us more on your intent & we will suggest you a good implementation – Ashfame Commented May 3, 2012 at 20:58
Add a comment  | 

1 Answer 1

Reset to default 6

You can use the user_register action to hook into the register proces and then create the user directory with wp_mkdir_p.

function create_user_dir($user_id) {
    $user_info = get_userdata( $user_id );

    $upload_dir = wp_upload_dir();
    $user_dir = $upload_dir['basedir'] . '/user_dirs/' . $user_info->user_login;

    wp_mkdir_p($user_dir);
}
add_action( 'user_register', 'create_user_dir');

This example makes a directory in uploads/user_dirs.

http://codex.wordpress/Plugin_API/Action_Reference/user_register
http://codex.wordpress/Function_Reference/wp_mkdir_p

Post a comment

comment list (0)

  1. No comments so far