PATH:
home
/
letacommog
/
laindinois
/
OLD
/
wp-content
/
plugins
/
dwt-listing-rest-api
/
classes
<?php /*----- Login Starts Here -----*/ add_action( 'rest_api_init', 'dwt_listing_login_api_hooks_get', 0 ); function dwt_listing_login_api_hooks_get() { register_rest_route( 'downtown/app', '/login/', array( 'methods' => WP_REST_Server::READABLE, 'callback' => 'dwt_listing_loginMe_get', 'permission_callback' => function () { return dwt_listing_basic_auth(); }, ) ); } if (!function_exists('dwt_listing_loginMe_get')) { function dwt_listing_loginMe_get() { global $dwt_listing_api; $data['logo'] = dwt_listing_appLogo(); $response = ''; $fields[] = array("placeholder" => __("Your Email", "dwt-listing-api"), "field_type_name" => 'email'); $fields[] = array("placeholder" => __("Your Password", "dwt-listing-api"), "field_type_name" => 'password'); $data['login_fields'] = $fields; $data['screen_txt'] = __("Sign in", "dwt-listing-api"); $data['btn_text'] = __("Sign In", "dwt-listing-api"); $data['already_account'] = __("Already have an account? Sign Up", "dwt-listing-api"); $data['main_heading'] = __("Find & explore world top places", "dwt-listing-api"); $data['separator'] = __("OR", "dwt-listing-api"); $data['facebook_btn'] = __("Facebook", "dwt-listing-api"); $data['google_btn'] = __("Google", "dwt-listing-api"); $data['forgot_text'] = __("Forgot Password", "dwt-listing-api"); $data['register_text'] = __("Not a Member Yet? Register with us.", "dwt-listing-api"); return $response = array( 'success' => true, 'data' => $data, 'message' => '' ); } } add_action( 'rest_api_init', 'dwt_listing_login_api_hooks_post', 0 ); function dwt_listing_login_api_hooks_post() { register_rest_route( 'downtown/app', '/login/', array( 'methods' => WP_REST_Server::EDITABLE, 'callback' => 'dwt_listing_loginMe_post', //'permission_callback' => function () { return dwt_listing_basic_auth(); }, ) ); } if (!function_exists('dwt_listing_loginMe_post')) { function dwt_listing_loginMe_post($request) { $response = ''; $json_data = $request->get_json_params(); $email = (isset($json_data['email'])) ? $json_data['email'] : ''; $name = (isset($json_data['name'])) ? $json_data['name'] : ''; $password = (isset($json_data['password'])) ? $json_data['password'] : ''; $remember = (isset($json_data['remember'])) ? $json_data['remember'] : ''; $type = (isset($json_data['type'])) ? $json_data['type'] : 'normal'; $creds = array(); $creds['remember'] = $remember; $creds['user_login'] = strtolower($email); $creds['user_password'] = strtolower($password); if($type == 'social') { if(!is_email($email)) { $response = array( 'success' => false, 'data' => '' , 'message' => __("Email address is not valid.", "dwt-listing-api") ); } else if( email_exists($email) == true ) { $user = get_user_by( 'email', $email ); if($user) { $user_id = $user->ID; $profile_arr = array(); $profile_arr['id'] = $user->ID; $profile_arr['user_email'] = $user->user_email; $profile_arr['display_name'] = $user->display_name; $profile_arr['profile_img'] = dwt_listing_get_user_dp($user->ID,'downtown-user-dp'); $profile_arr['package'] = dwt_listing_check_package_history_app('',$user->ID); $response = array( 'success' => true, 'data' => $profile_arr, 'message' => __("Login Successfull", "dwt-listing-api") ); } } else { $password = mt_rand (1000,999999); $uid = dwt_listing_do_socialregister_apps($name, $email, $password); if ( function_exists( 'dwt_listing_email_on_new_user' ) ) { dwt_listing_email_on_new_user($uid, $password); } $user = get_user_by( 'id', $uid); { if($user) { $user_id = $user->ID; $profile_arr = array(); $profile_arr['id'] = $user->ID; $profile_arr['user_email'] = $user->user_email; $profile_arr['display_name'] = $user->display_name; $profile_arr['profile_img'] = dwt_listing_get_user_dp($user->ID,'downtown-user-dp'); $profile_arr['package'] = dwt_listing_check_package_history_app('',$user->ID); $response = array( 'success' => true, 'data' => $profile_arr, 'message' => __("Login Successfull", "dwt-listing-api") ); } } } } else { $user = wp_signon( $creds, false ); if ( is_wp_error($user) ) { $response = array( 'success' => false, 'data' => '' , 'message' => __("Invalid Login Details", "dwt-listing-api") ); } else { $profile_arr = array(); $profile_arr['id'] = $user->ID; $profile_arr['user_email'] = $user->user_email; $profile_arr['display_name'] = $user->display_name; $profile_arr['profile_img'] = dwt_listing_get_user_dp($user->ID,'downtown-user-dp'); $profile_arr['package'] = dwt_listing_check_package_history_app('',$user->ID); $response = array( 'success' => true, 'data' => $profile_arr, 'message' => __("Login Successfull", "dwt-listing-api") ); } } return $response; } } if( ! function_exists( 'dwt_listing_do_socialregister_apps' ) ) { function dwt_listing_do_socialregister_apps($display_name = '', $email = '', $password = '') { $u_name = dwt_listing_check_user_name( $display_name ); $uid = wp_create_user( $u_name, $password, $email ); wp_update_user( array('ID' => $uid, 'display_name' =>$u_name)); return $uid; } }
[+]
..
[-] events.php
[edit]
[-] author-listings.php
[edit]
[-] fetch_data.php
[edit]
[-] forget.php
[edit]
[-] categories.php
[edit]
[-] listing-detail.php
[edit]
[-] packages.php
[edit]
[-] home.php
[edit]
[+]
packages
[-] reviews.php
[edit]
[+]
submit-listing
[-] profile.php
[edit]
[-] register.php
[edit]
[-] settings.php
[edit]
[-] events-search.php
[edit]
[-] listing-search.php
[edit]
[+]
profile
[-] event-detail.php
[edit]
[-] login.php
[edit]
[+]
payments
[-] blog.php
[edit]