• Is there a way to automatically create a category for each user that signs up, and then bind that user to their category? I’m looking into the bind user to category plugin. I’m not even sure if it works for 2.7 (although a simple test will tell me that).

    I’m also not afraid to get into the source, so if somebody can point me in the right direction, I have no problem writing code to create categories for users upon signup…

    Thanks in advance!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter rockwell08

    (@rockwell08)

    Thank you for the reply. While I’m not new to PHP, I am new to writing plugins for WordPress, so I have what is probably a very simple question…

    I am using the following line to add functionality to the user_register hook…

    add_action ( ‘user_register’, ‘jarredsUserCategory’ );

    and I have a jarredsUserCategory function that I will use to do this. I’ve run a simple javascript alert that works, so I know that it’s being fired. The thing I can’t figure out is how to get the newly created user’s ID. I will be creating the categories based on the user ID, so if I can get that, then I’m fairly certain I can create new categories in the database with no problem. I’m just not sure where to grab that ID from in my function call.

    Again, thanks in advance for any help…

    Thanks,
    Jarred

    Thread Starter rockwell08

    (@rockwell08)

    Ok, I got it, it was much easier than I anticipated it to be. I hope this helps somebody else along their way…

    The add_action(‘user_register’, ‘jarredsUserCategory);

    link calls a function that I’ve written, named jarredsUserCategory. The user_register hook returns a $user_id variable to be used, it’s just not passed in the typical manner that variables are passed between functions (as far as how you know it’s being passed). You still use it exactly the same in your own function.

    So, for example, the jarredsUserCategory plugin file may look like:

    function jarredsUserCategory($user_id) {
    echo($user_id);
    }

    add_action ( ‘user_register’, ‘jarredsUserCategory’ );

    So there it is, it’s much more simple than I had anticipated it to be. WordPress continues to make me happy…

    The function that you create can be anything you like, I’m going to try to use it to create categories for each individual user that signs up. Now actually naming the category properly so it’s display name makes sense and looks right, and actually getting the user to only post to that category are completely different things, but 1 thing at a time, right?

    Thanks again!

    you can also use ‘user_nicename’ field.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘User Categories in 2.7’ is closed to new replies.