Guest User

Untitled

a guest
Mar 22nd, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. $query = $this->db->update(
  2. //do something
  3. );
  4.  
  5. if($query == 0)
  6. {
  7. $this->setMessage('error', 'There was an error: ' . $this->db->print_error());
  8. }
  9. else
  10. {
  11. wp_redirect(site_url('/user_data/'));
  12. }
  13.  
  14. public function redirect($url = false)
  15. {
  16. if(headers_sent())
  17. {
  18. $destination = ($url == false ? 'location.reload();' : 'window.location.href="' . $url . '";');
  19. echo die('<script>' . $destination . '</script>');
  20. }
  21. else
  22. {
  23. $destination = ($url == false ? $_SERVER['REQUEST_URI'] : $url);
  24. header('Location: ' . $destination);
  25. die();
  26. }
  27. }
  28.  
  29. add_action ('wp_loaded', 'clean_admin_referer');
  30. function clean_admin_referer() {
  31.  
  32. if ( isset( $_REQUEST['condition1']) && isset($_REQUEST['condition2']) ) {
  33.  
  34. if (current_user_can('administrator')) {
  35.  
  36. <!-- do your database magic -->
  37.  
  38. $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'condition1', 'condition2' ));
  39.  
  40. wp_redirect($_SERVER['REQUEST_URI']);
  41.  
  42. }
  43. }
Add Comment
Please, Sign In to add comment