thumb After making an update to one of my WordPress plugins, when trying to load plugin settings page, I get the following error message:

Fatal error: Can’t use function return value in write context in /public_html/domain-name.com/wp-content/plugins/rss-feed-icon-for-specificfeedscom/inc/php/functional.php on line 19

For WordPress users, I recommend reading another article about this error.

What causes this error

This error message is self explanatory. It means that we are trying to use function to return value in write context. It also tells us where exactly this error occurred. To solve this issue, follow the steps below.

How to solve it

  1. Open the file that is mentioned in the error message. In my case this is the functional.php file, which is placed in the /public_html/domain-name.com/wp-content/plugins/rss-feed-icon-for-specificfeedscom/inc/php/ directory.

  2. Find the line specified in the error message. In my case this is the 19th line.

  3. Here you can see the code that causes the error. That’s what it looks like in my case:

if ( ! empty( get_option( 'my_option' ) ) {

Note! You can see something similar to this but with isset() or another PHP function, and with custom function instead of WordPress function get_option(). For example:

if ( ! empty( myFunction( $myVariable ) ) {

or:

if ( isset( $_POST( 'my_option' ) == TRUE ) ) {

All I had to do to solve this error was to change the code above to the following:

if ( ! get_option( 'my_option' ) )

This code does exactly the same thing but in more elegant way. Also we can make a variable and then use it in the our if construction:

$my_option = get_option( 'my_option' );
if ( ! empty( $my_option ) {

Done! Now your plugin should work without this error.

Thanks for reading!


Arthur Gareginyan

Arthur Gareginyan

Arthur is a designer and full stack software engineer. He is the founder of MyCyberUniverse.com. His personal website can be found at arthurgareginyan.com. Check out his free WordPress plugins at wordpress.org.

Follow Arthur: