Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a custom meta box with a dropdown displaying all the WP users via wp_dropdown_users. It saves which WP user is chosen with the post, so that all works.

However, is there a way to make it show the selected user in the dropdown when going back to edit, rather than the first in the list? I've used the selected() function for another dropdown but I've created that dynamically. I've tried to implement selected() with wp_dropdown_users, but it hasn't worked so I'm not sure if it's even possible?

Thanks!

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You need to set selected argument for the wp_dropdown_users function. Do it like this:

wp_dropdown_users( array( 
    // ...
    'selected' => $user_id,
    // ...
) );

Read documentation for wp_dropdown_users function

share|improve this answer
    
Thank you! I thought it was that at first but I thought it required an actual ID number. End of semester, brain not working right. Thanks again! –  CourtFantinato Apr 14 '12 at 17:11
    
You are welcome! –  Eugene Manuilov Apr 14 '12 at 18:18
add comment

Your Answer

 
discard

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.