• How can I put a null position in the drop down author selector and make this choice mandatory?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    You mean a blank selection? Do not use a label for the option:
    <option value="foo" selected></option>
    You still need to assign a value so the code processing the form knows which option was selected.

    Mandatory choice? Then why offer other options? Or do you mean the default choice? The option with the “selected” attribute will be the default choice.

    Thread Starter sacconi

    (@sacconi)

    post=apartment, author=agency, each time I edit a post I need to remember to select an “author”, so, which is the solution for not forgetting this step?

    Moderator bcworkz

    (@bcworkz)

    I’m sorry, disregard my last reply. I mis-read your post and answered a question you didn’t ask.

    You have to assign an author to all posts, it cannot be a null value. It is feasible to use the “wp_insert_post_data” filter to force the author of all posts (or those fitting specific criteria) to be a particular user regardless of who the actual creator is. Set the ‘post_author’ element of the passed array to whatever user ID you want, then return the modified array.

    It’s also possible to run a custom UPDATE query in phpMyAdmin to change the post_author field of all existing posts to a specific user ID if they fit specific criteria.

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

The topic ‘Null position’ is closed to new replies.