Post author field supported?

Support General Post author field supported?Resolved

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #18261
    Ryan LauritsenRyan Lauritsen
    Participant

    Is a Meta Box field for the post author to replace the default WP author field supported?

    If so, what is needed?

    I've tried setting the id to author and post_author based on this topic (and the linked tutorial) https://support.metabox.io/topic/can-a-default-wp-post-table-field-be-added-to-a-metabox-tab-ie-post_author/

    but the Meta Box field is not populating with a saved post's author.

    Here is my field:

    array(
        'name' => 'Author',
        'id' => 'author',
        'type' => 'user',
        'field_type'  => 'select_advanced',
        'placeholder' => '-- Select Author --',
        'query_args'  => array(
        'role' => 'my_custom_role',
            'number' => 10,
        ),
        'js_options' => array(
            'minimumInputLength' => 3,
        ),
    ),
    #18269
    Anh TranAnh Tran
    Keymaster

    Hi Ryan,

    Yes, that's doable. You need to set the field ID to post_author and hook to not save it to post meta. Please see this tutorial for doing that.

    #18289
    Ryan LauritsenRyan Lauritsen
    Participant

    Thanks, Anh Tran. I've got it working now. Is it possible to customize the data being searched? For example, have it only search the email and not URL, username, or display_name?

    #18290
    Ryan LauritsenRyan Lauritsen
    Participant

    Maybe a better question is... Can we access the search term typed into a select_advanced field within the query_args parameter so that we can create a more sophisticated search query?

    #18297
    Anh TranAnh Tran
    Keymaster

    Hi Ryan, we use the default search functionality from WP. See the search param here. So it searches users by email address, URL, ID, username or display_name.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.