Skip to main content
replaced http://wordpress.stackexchange.com/ with https://wordpress.stackexchange.com/
Source Link

There's actually some cool filters that allow you to pre-populate the title field and editor field, the one we need is default_title. Once in the hook, we need to get our user and display the name:

function post_author_title( $post_title, $post ) {
    if( $post->post_type == 'your_post_type' ) {
        $user = wp_get_current_user();
    
        $post_title = $user->display_name;
    }
    
    return $post_title;
}
add_filter( 'default_title', 'post_author_title', 10, 2 );

You can try the above but if the title box is removed I'm not sure if this will work. Another option is to manually add the title once the post is saved:

Answer LinkAnswer Link

Author - chrisguitarguyAuthor - chrisguitarguy

function wpse67262_change_title( $data ) {
    if( 'your_post_type' != $data['post_type'] )
        return $data;
    
    $user = wp_get_current_user();
    $data['post_title'] = $user->display_name;

    return $data;
}
add_filter( 'wp_insert_post_data', 'wpse67262_change_title' );

Hopefully one of those functions work for you!

There's actually some cool filters that allow you to pre-populate the title field and editor field, the one we need is default_title. Once in the hook, we need to get our user and display the name:

function post_author_title( $post_title, $post ) {
    if( $post->post_type == 'your_post_type' ) {
        $user = wp_get_current_user();
    
        $post_title = $user->display_name;
    }
    
    return $post_title;
}
add_filter( 'default_title', 'post_author_title', 10, 2 );

You can try the above but if the title box is removed I'm not sure if this will work. Another option is to manually add the title once the post is saved:

Answer Link

Author - chrisguitarguy

function wpse67262_change_title( $data ) {
    if( 'your_post_type' != $data['post_type'] )
        return $data;
    
    $user = wp_get_current_user();
    $data['post_title'] = $user->display_name;

    return $data;
}
add_filter( 'wp_insert_post_data', 'wpse67262_change_title' );

Hopefully one of those functions work for you!

There's actually some cool filters that allow you to pre-populate the title field and editor field, the one we need is default_title. Once in the hook, we need to get our user and display the name:

function post_author_title( $post_title, $post ) {
    if( $post->post_type == 'your_post_type' ) {
        $user = wp_get_current_user();
    
        $post_title = $user->display_name;
    }
    
    return $post_title;
}
add_filter( 'default_title', 'post_author_title', 10, 2 );

You can try the above but if the title box is removed I'm not sure if this will work. Another option is to manually add the title once the post is saved:

Answer Link

Author - chrisguitarguy

function wpse67262_change_title( $data ) {
    if( 'your_post_type' != $data['post_type'] )
        return $data;
    
    $user = wp_get_current_user();
    $data['post_title'] = $user->display_name;

    return $data;
}
add_filter( 'wp_insert_post_data', 'wpse67262_change_title' );

Hopefully one of those functions work for you!

I did test function 2, they both work - so I removed my indecisiveness
Source Link
Howdy_McGee
  • 20.8k
  • 24
  • 91
  • 175

There's actually some cool filters that allow you to pre-populate the title field and editor field, the one we need is default_title. Once in the hook, we need to get our user and display the name:

function post_author_title( $post_title, $post ) {
    if( $post->post_type == 'your_post_type' ) {
        $user = wp_get_current_user();
    
        $post_title = $user->display_name;
    }
    
    return $post_title;
}
add_filter( 'default_title', 'post_author_title', 10, 2 );

You can try the above but if the title box is removed I'm not sure if this will work. Another option is to manually add the title once the post is saved:

Answer Link

Author - chrisguitarguy

function wpse67262_change_title( $data ) {
    if( 'your_post_type' != $data['post_type'] )
        return $data;
    
    $user = wp_get_current_user();
    $data['post_title'] = $user->display_name;

    return $data;
}
add_filter( 'wp_insert_post_data', 'wpse67262_change_title' );

The above I haven't tested, this is just what I found on the exchange, hopefullyHopefully one of those functions work for you!

There's actually some cool filters that allow you to pre-populate the title field and editor field, the one we need is default_title. Once in the hook, we need to get our user and display the name:

function post_author_title( $post_title, $post ) {
    if( $post->post_type == 'your_post_type' ) {
        $user = wp_get_current_user();
    
        $post_title = $user->display_name;
    }
    
    return $post_title;
}
add_filter( 'default_title', 'post_author_title', 10, 2 );

You can try the above but if the title box is removed I'm not sure if this will work. Another option is to manually add the title once the post is saved:

Answer Link

Author - chrisguitarguy

function wpse67262_change_title( $data ) {
    if( 'your_post_type' != $data['post_type'] )
        return $data;
    
    $user = wp_get_current_user();
    $data['post_title'] = $user->display_name;

    return $data;
}
add_filter( 'wp_insert_post_data', 'wpse67262_change_title' );

The above I haven't tested, this is just what I found on the exchange, hopefully one of those functions work for you!

There's actually some cool filters that allow you to pre-populate the title field and editor field, the one we need is default_title. Once in the hook, we need to get our user and display the name:

function post_author_title( $post_title, $post ) {
    if( $post->post_type == 'your_post_type' ) {
        $user = wp_get_current_user();
    
        $post_title = $user->display_name;
    }
    
    return $post_title;
}
add_filter( 'default_title', 'post_author_title', 10, 2 );

You can try the above but if the title box is removed I'm not sure if this will work. Another option is to manually add the title once the post is saved:

Answer Link

Author - chrisguitarguy

function wpse67262_change_title( $data ) {
    if( 'your_post_type' != $data['post_type'] )
        return $data;
    
    $user = wp_get_current_user();
    $data['post_title'] = $user->display_name;

    return $data;
}
add_filter( 'wp_insert_post_data', 'wpse67262_change_title' );

Hopefully one of those functions work for you!

Source Link
Howdy_McGee
  • 20.8k
  • 24
  • 91
  • 175

There's actually some cool filters that allow you to pre-populate the title field and editor field, the one we need is default_title. Once in the hook, we need to get our user and display the name:

function post_author_title( $post_title, $post ) {
    if( $post->post_type == 'your_post_type' ) {
        $user = wp_get_current_user();
    
        $post_title = $user->display_name;
    }
    
    return $post_title;
}
add_filter( 'default_title', 'post_author_title', 10, 2 );

You can try the above but if the title box is removed I'm not sure if this will work. Another option is to manually add the title once the post is saved:

Answer Link

Author - chrisguitarguy

function wpse67262_change_title( $data ) {
    if( 'your_post_type' != $data['post_type'] )
        return $data;
    
    $user = wp_get_current_user();
    $data['post_title'] = $user->display_name;

    return $data;
}
add_filter( 'wp_insert_post_data', 'wpse67262_change_title' );

The above I haven't tested, this is just what I found on the exchange, hopefully one of those functions work for you!