Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Custom Login Engine
- function custom_login() {
- global $errors;
- if ( isset( $_POST['submit'] ) && ( $_POST['submit'] == 'submit' )) {
- if ( ! isset( $_POST['czystespalanie__nonce__field'] ) || ! wp_verify_nonce( $_POST['czystespalanie__nonce__field'], 'czystespalanie__nonce__cf_msg' )) {
- print '<h1>Sorry, but <strong><i>something went wrong.</i></strong> Contact with admin </h1>';
- return;
- }
- $res = czystespalanie__post_captcha( $_POST['g-recaptcha-response'] );
- if ( !$res['success'] ){
- $errors = 'Udowodnij, że nie jesteś robotem i zaznacz pole reCaptcha lub wykonaj instrukcje z obrazka.';
- } else {
- $login_data = array();
- $login_data['user_login'] = sanitize_user($_POST['log']);
- $login_data['user_password'] = esc_attr($_POST['pwd']);
- $user = wp_signon( $login_data, false );
- if ( is_wp_error( $user ) ) {
- $errors = 'Niepoprawny login lub hasło.';
- } else {
- wp_clear_auth_cookie();
- wp_set_current_user( $user->ID, $user->user_login );
- wp_set_auth_cookie( $user->ID );
- $redirect_to = ( is_array( $user->roles ) && in_array( 'administrator', $user->roles ) ) ? admin_url() : home_url('/forum');
- wp_safe_redirect( $redirect_to );
- exit;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement