Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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 !=

Matt Campbell
Matt Campbell
9,767 Points

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