WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I installed a plugin called "Symbiosis" which creates categories automatically copying a user's username upon them signing up.

Whenever any user creates a post on the site, I am trying to figure out how to assign that category that was already created with the new post.

I want to set WP Default Category to the authors username so that when anyone creates a post it automatically posts under their name. (my users do not have access to default wp-panels)

I know about the dropdown in the settings > writing panel but that's not what I'm looking for as I cannot customize the slug to a users username.

Is this possible via plugin or programatically somewhere else?

The categories are all already created. I can pull the loggedin users username and echo it but I'm not sure where to put it:

<?php global $current_user; if ( isset($current_user) ) {echo $current_user->user_login;}?>
share|improve this question

The default category is stored in the options table under option named default_category , so you can do something like this:

function set_user_default_cat_wpa89057(){
    global $current_user; 
    if ( isset($current_user) ) {
        update_option( 'default_category',  $current_user->user_login);
share|improve this answer
function setcategory_2_username($id){
   global $current_user;  
   $category_id = get_cat_ID( $current_user->user_login );
   wp_set_post_categories( $post_id, array($category_id) );
add_action('save_post', 'setcategory_2_username');
share|improve this answer
There's a WYSIWYG editor when writing an answer that helps you with formatting. And please explain why this is the solution. – kaiser Mar 2 '13 at 15:00
This code cannot work as written. Your callback parameter is $id but you are using post_id with wp_set_post_categories() – s_ha_dum May 6 '14 at 10:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.