Home Forums Backend Issues (wp-admin) Default to current user with user field


Default to current user with user field

  • My client would like me to add a column to the admin view of a custom post type. I just found Codepress Admin Columns (, which does this easily. But one of the columns they want doesn’t appear to be an existing bit of data saved with each post record: They’d like to see which user last modified the record.

    I thought maybe I could add an ACF user field to the custom post type and have it default to the current user… There isn’t a default setting for this field and I’m wondering if this is possible. Thoughts?


  • Hi!

    I honestly think you’ll be better of creating this yourself..

    simply do an update_post_meta on the wp_save_post hook.. something like this (not tested):

    function save_book_meta($post_id) {
        $slug = 'book'; //CHANGE THIS TO THE SLUG OF YOUR POST TYPE
        /* check whether anything should be done */
        $_POST += array("{$slug}_edit_nonce" => '');
        if ( $slug != $_POST['post_type'] ) {
        if ( !current_user_can( 'edit_post', $post_id ) ) {
    $current_user = wp_get_current_user();
       update_post_meta($post_id, 'latest_author', $current_user-> display_name);
    add_action( 'save_post', 'save_book_meta');

    This will save the current users display name as a custom field called “latest_author”.

  • Thanks, I’ll give this a try!

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Default to current user with user field’ is closed to new replies.