WPManageNinja / easy-code-manager

The High-Performance File Based Code Snippet Plugin for WP
https://fluentsnippets.com
24 stars 9 forks source link

Conditional Logic "User / logged in" not working #21

Open eatse21 opened 6 months ago

eatse21 commented 6 months ago

The issue is here: https://github.com/WPManageNinja/easy-code-manager/blob/793c3144e731c0e734418f41f1a2b8d8c3bc3090/app/Services/FluentSnippetCondition.php#L55-L59

It directly returns the value of is_user_logged_in() without applying any conditional logic. So if the user is connected, the snippet always runs, and if not, it will never do

I quickly resolved that using this patch, but maybe you have a better way to do this in your codebase

if ($key == 'authenticated') {
  return $value == (is_user_logged_in() ? 'yes' : 'no');
}