Support » Plugins » [Plugin: Widget Logic] Can’t have ‘return’ in function name

  • I was trying to use Widget Logic with a custom function of my own, and ran into a problem. I made a function called is_return_visitor() to tell me if the current visitor was either a logged-in user or someone who had previously left a comment on my site.

    Widget Logic threw a parse error.

    The reason is because of the way it handles the option to say return(foo). If you see the string ‘return’ anywhere in the Widget Logic condition, you try to parse the code directly, instead of wrapping it in your own ‘return’ statement. So, because my function was named ‘is_return_visitor’, Widget Logic thought I was using my own return statement.

    You might consider changing the simple string comparison to a regex, to more accurately detect that.

    In the meantime, I just renamed my function to is_repeat_visitor().

Viewing 1 replies (of 1 total)
  • Sorry about that – I’ll try to find some foolproof way to check if the WL contains a proper return.

    the work around is that IF you have the string ‘return’ in your WL anywhere (as you do in the name of a function) that you have to then add an ACTUAL return and final semi-colon

    eg return is_return_visitor(foo);

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Widget Logic] Can’t have ‘return’ in function name’ is closed to new replies.