Advertisement
Guest User

Untitled

a guest
Jul 8th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'log-in' ) :
  2. global $error;
  3. $login = wp_login( $_POST['user-name'], $_POST['password'] );
  4. $login = wp_signon( array( 'user_login' => $_POST['user-name'], 'user_password' => $_POST['password'], 'remember' => $_POST['remember-me'] ), false );
  5.  
  6. if (!$error) {
  7. save_message( 'success', __( 'You have successfully Login.', 'frontendprofile' ) );
  8. unset($_POST);
  9. wp_redirect( get_permalink( 4 ) );
  10. }
  11. // wp_redirect( home_url() );
  12. endif;
  13.  
  14. <?php
  15. if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'log-in' ) :
  16.  
  17. $login = wp_signon( array( 'user_login' => $_POST['user-name'], 'user_password' => $_POST['password'], 'remember' => $_POST['remember-me'] ), false );
  18.  
  19. if ( !is_wp_error($login) ){
  20. save_message( 'success', __( 'You have successfully Login.', 'frontendprofile' ) );
  21. unset($_POST);
  22. wp_redirect( get_permalink( 4 ) );
  23. }
  24.  
  25. endif;
  26. ?>
  27.  
  28. <?php
  29. function parse_user($info = null, $return = 'object') {
  30. if ( is_null( $info ) ) {
  31. global $current_user;
  32. if ( empty( $current_user->ID ) ) return null;
  33. $info = get_userdata( $current_user->ID );
  34. }
  35. elseif ( empty( $info ) ) {
  36. return null;
  37. }
  38. if( $return == 'ID' ) {
  39. if ( is_object( $info ) ) return $info->ID;
  40. if ( is_numeric( $info ) ) return $info;
  41. }
  42. elseif( $return == 'object' ) {
  43. if ( is_object( $info ) && $info->ID) return $info;
  44. if ( is_object( $info )) return get_userdata( $info->ID );
  45. if ( is_numeric( $info ) ) return get_userdata( $info );
  46. if ( is_string( $info ) ) return get_userdatabylogin( $info );
  47. }
  48. else {
  49. return null;
  50. }
  51. }
  52.  
  53. function wp_login_user_po9856($username, $password, $remember) {
  54. // Get the user based on the username from the POST
  55. $user = parse_user($username);
  56.  
  57. // Remove html tags from the variables
  58. $username = strip_tags($username);
  59. $password = strip_tags($password);
  60.  
  61. // Validate the Form Data
  62. if(!wp_check_password( $password_stripped, $user->user_pass ) ) return new WP_Error('incorrect_password', "Wrong Password!");
  63.  
  64. // User login
  65. $login = wp_signon(array('user_login' => $username, 'user_password' => $password, 'remember' => (bool)$remember));
  66. if (is_wp_error($login))
  67. return $login;
  68.  
  69. // Unset
  70. unset($_POST);
  71.  
  72. // Custom Message
  73. save_message( 'success', __( 'You have successfully Login.', 'frontendprofile' ) );
  74.  
  75. // Redirection
  76. wp_redirect(get_permalink( 4 ));
  77. }
  78. if ( 'POST' == $_SERVER['REQUEST_METHOD'] && @$_POST['action'] == 'log-in')
  79. {
  80. wp_login_user_po9856($_POST['user-name'], $_POST['password'], $_POST['remember-me']);
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement