WordPress How to Build a WordPress Plugin Building a WordPress Plugin Settings Page CRUD with the WordPress Options Table: Part 2

Chris Stuntz
Chris Stuntz
13,160 Points

stuck on crud with the wordpress options table part 2

I must be seeing something here! This appears correct to me! but it is not passing!

    require('includes/page-wrapper.php');

$options = get_option('my_plugin_options');

if( $options != ''){ $my_plugin_username = $options['my_plugin_username']; }

5 Answers

Chris Stuntz
Chris Stuntz
13,160 Points

Completed! I should have used !empty instead of !=

What's this?

$options != ''

If options doesn't equal what?

Chris Stuntz
Chris Stuntz
13,160 Points

the conditional test if the options array is not blank

Asim Qasimzade
Asim Qasimzade
9,015 Points

You should use isset() function instead of $options != "" or $options != empty

if (isset($options)){ $my_plugin_username = $options ['my_plugin_username']; }

Don't use:

!empty

It's just:

$options = get_option('my_plugin_options');
if( $options != '' ) {
        $wptreehouse_username = $options['wptreehouse_username'];
    }

From nejc's answer here:

https://teamtreehouse.com/forum/im-getting-the-white-screen-of-death