Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. // Custom Button on users.php - ADMIN
  2. //add additional columns to the users.php admin page
  3. add_filter('manage_users_columns', 'activate_user_in_table');
  4.  
  5. function activate_user_in_table( $column ){
  6. $column['active'] = 'Activeer';
  7. return $column;
  8. }
  9.  
  10. add_filter('manage_users_custom_column', 'add_display_value', 50, 3);
  11. function add_display_value( $value, $column_name, $user_id ){
  12. $user = get_user_meta( $user_id );
  13.  
  14. // Get the current status from the user.
  15. $value = $user['sophima_user_active'][0];
  16.  
  17. // Based on the output 1 or 0 I have to create the button to activate or desactivate the user.
  18. switch ($value) {
  19. case 1 :
  20. $button = '<a href="'.add_query_arg(array('block' => '0','user_id' => $user_id)).'" name="display_as-'.$user_id.'" class="button green">Blokkeren</a>';
  21. return $button;
  22. break;
  23.  
  24. case 0 :
  25. $button = '<a href="'.add_query_arg(array('activate' => '1','user_id' => $user_id)).'" name="display_as-'.$user_id.'" class="button green">Activeer</a>';
  26. update_usermeta($user_id, 'sophima_user_active', 0 );
  27.  
  28. return $button;
  29. break;
  30. default:
  31. }
  32.  
  33. return $value;
  34. }
  35.  
  36. update_usermeta($user_id, 'sophima_user_active', 1 );
  37.  
  38. update_usermeta($user_id, 'sophima_user_active', 1 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement