$user = get_user_by_email($email);

if($user && wp_check_password( $pass, $user->data->user_pass, $user->ID))

{

$all_meta_for_user = get_user_meta( $user->ID );

$userdata = array(’email’ => $user->data->user_email, ‘full_name’ =>$user->data->display_name, “user_id” => $user->ID);

foreach($all_meta_for_user as $k=>$v)

{

//$userdata[$k] = $v[0];

if($k == “user_image_id”)

{

$pic = wp_get_attachment_image_src( $v[0]);

if(sizeof($pic)>0){

$userdata[‘user_image’] = $pic[0];

}

else

{

$userdata[‘user_image’] = ‘No Profile Pic.’;

}

}

else

{

$userdata[$k] = $v[0];

}

}

//$user_image = wp_get_attachment_image_src( $userdata[‘user_image_id’]);

//$userdata[‘user_image’] = $user_image[0];

//$fieldlist = array(‘contact_no’,’business_title’,’zip’,’country’,’state’,’city’,’street’,’rate’,’gender’,’aboutme’,’expyears’,’expmonths’,’availfrom’,’availto’,’aboutskill’,’degree’,’passyear’,’university’,’currency’,’ratetype’);

$fieldlist = array(“email”, “gender”, “business_title”, “street”, “city”, “state”, “country”, “zip”, “lat”, “lng”, “contact_no”, “rate”, “aboutme”, “expyears”, “expmonths”, “availfrom”, “availto”, “aboutskill”, “degree”, “passyear”, “university”, “ratetype”, “user_image”, “currency” );

$availablelist = array_keys($userdata);

$new_field = array_diff($fieldlist,$availablelist);

foreach($new_field as $k)

{

$userdata[$k] = ”;

}

$return = array(“status”=>true,”message”=>”Logged in successfully.”,”data”=>$userdata);

Leave a Reply