function does not return true or false in php for no reason

  html, php, templates, wordpress

First, I should say that I created a template file for wordpress.
Now the problem is that I created a function and it does not work for no reason ! I could remove the function but I wonder why this is not working !

(I’m 100% sure that those 2 variables are different because I printed them)

The function always returns true even though my variables are different ! I tested it and I also wanted to echo the function out but the page does not load !

Very very strange !

The code :

global $wpdb;
$lid = $_GET['lid'];
$row = $wpdb->get_row($wpdb->prepare("SELECT * FROM wp_edit_gf WHERE lid = $lid"), ARRAY_A);
global $current_user;
$user_id = $current_user->ID;
$user = get_user_by('id', $user_id);
$user_email=$user->user_email; 
$lid_mail = $row['user_mail'];
function gfedit_verify_user_entry(){
    if(isset($_GET['lid']) && $lid_mail == $user_email){
        return true;
    }
    else{
        return false;
    }
}
if(!is_user_logged_in()){
    header("Location: https://example.com/my-account/?login=true&back=home&page=1");
    exit();
}
elseif(!gfedit_verify_user_entry()){
    echo "access denied!";
}
else{
.
.
.

Source: Ask PHP

LEAVE A COMMENT