You cant write PHP code inside the widget so you need to modify the plugin code.
1. Open file qa-wa-layer.php and locate this foreach loop: https://github.com/svivian/q2a-widget-anywhere/blob/41172e294af6a1efade322da4465897348fb3869/qa-wa-layer.php#L81
2. Edit it this way:
foreach ($this->wanyw_widgets as $wid) {
if ($wid['position'] !== $pos) {
continue;
}
switch ($wid['id']) {
case 1:
if (qa_is_logged_in()) {
$this->output($wid['content']);
}
break;
case 2:
if (!qa_is_logged_in()) {
$this->output($wid['content']);
}
break;
default:
$this->output($wid['content']);
}
}
3. Edit the case 1 and case 2 so that the number is actually the widget ID. You can see the widget ID when you edit a widget, in the URL, e.g. here is a 1 in the URL: admin/widgetanyw?editid=1
In this case, 1 is for logged in users only. And 2 is for anonyous users only.