I have some text in database1 and database2 tables that must match can_do($can, $user_id) function and if it doesn't match it will return false.
The problem is it checks both tables and returns false when database1 is set but database2 is not set. I need it to return true if database1 is set even if the database2 is not set and vice versa. How can I achieve that?
Here is the code:
function can_do( $can, $user_id ) {
if ( $can ) {
$test1 = get_user_meta( $user_id, 'database1', true );
$test2 = get_user_meta( $user_id, 'database2', true );
$function = get_functionvalue();
if($test1 != $function OR $test2 != $function ) {
$can = false;
}
}
return $can;
}
add_filter( 'custom_wordpress_can_do', 'can_do', 10, 3 );