Advertisement
eventsmanager

Add other wp roles in event author dropdown

Feb 2nd, 2016
915
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. /*
  2. * This snippet will include other wp roles in event author dropdown
  3. */
  4.  
  5. function my_em_override_wp_dropdown_uses($output){
  6. global $post, $user_ID;
  7. if( in_array($post->post_type, array(EM_POST_TYPE_EVENT, EM_POST_TYPE_LOCATION,'event-recurring')) ){
  8. // return if this isn't the theme author override dropdown
  9. if (!preg_match('/post_author_override/', $output)) return $output;
  10.  
  11. // return if we've already replaced the list (end recursion)
  12. if (preg_match ('/post_author_override_replaced/', $output)) return $output;
  13.  
  14. // replacement call to wp_dropdown_users
  15. $output = wp_dropdown_users(array(
  16. 'echo' => 0,
  17. 'name' => 'post_author_override_replaced',
  18. 'selected' => empty($post->ID) ? $user_ID : $post->post_author,
  19. 'include_selected' => trues
  20. ));
  21.  
  22. // put the original name back
  23. $output = preg_replace('/post_author_override_replaced/', 'post_author_override', $output);
  24. }
  25. return $output;
  26. }
  27. add_filter('wp_dropdown_users', 'my_em_override_wp_dropdown_uses');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement