Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. <?php global $current_user; if ( isset($current_user) ) {echo $current_user->user_login;}?>
  2.  
  3. add_action('admin_init','set_user_default_cat_wpa89057');
  4. function set_user_default_cat_wpa89057(){
  5. global $current_user;
  6. if ( isset($current_user) ) {
  7. update_option( 'default_category', $current_user->user_login);
  8. }
  9. }
  10.  
  11. function setcategory_2_username($id){
  12. global $current_user;
  13. $category_id = get_cat_ID( $current_user->user_login );
  14. wp_set_post_categories( $post_id, array($category_id) );
  15. }
  16. add_action('save_post', 'setcategory_2_username');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement