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 trialPhil Purves
9,827 PointsCode challenge description not clear enough - or is there a bug?
I've repeatedly returned to this code challenge and got the 'Bummer' message… (see code and attached pic). Either the question is asking for something that isn't properly explained or there's a bug
- the pic will show you what I mean
Thanks for any help Phil P
<?php
function my_plugin_options_page() {
if (!current_user_can('manage_options')) {
wp_die('You do not have sufficient permissions to access this page.');
}
}
?>
4 Answers
Joel Bardsley
31,249 PointsHi Phil, I'm not able to see your attached image, but here's what I've noticed:
Your answer to Challenge 2 is correct aside from a missing semi-colon:
$my_plugin_username = esc_html( $_POST['my_plugin_username'] ); // add semi-colon to the end
However your conditional from Challenge 1 looks wrong:
if( isset( $POST['my_plugin_hidden_fieldsubmitted'] ) ) {
Should be $_POST (missing underscore) and ['my_plugin_hidden_field']. Also escaping the html of the hidden field and having an extra if statement to check its value is unnecessary.
Phil Purves
9,827 PointsThanks Joel - I'm sure I had a semi-colon there on several attempts but I'll revisit and try again. Pasting the code into the this help form area seemed to lead to issues so I'll upload more carefully if problems persists - will let you know. Cheers, Phil
Phil Purves
9,827 Points... same problem with semi-colon. The challenge question doesn't make it clear whether whether the form inputs/method etc have to be stated. In Zac's work this is done in a separate file. Phil - (please see my latest upload/community-help-query)
Phil Purves
9,827 PointsHi again - have tried all alterations suggested to no avail. Last warning message: "Bummer! You should pass the posted form element my_plugin_username into esc_html in order to sanitize it" The challenge does not instruct you to restate the form input/method etc, and in Zac's worked example he does that in a separate file under a postbox class.
Still bamboozled by this! - Phil
Phil Purves
9,827 PointsPhil Purves
9,827 PointsSorry - here's the response code (not showing above): ( and this was the challenge: Challenge Task 2 of 3 ... Below the first if statement, write a conditional statement to test if the my_plugin_hidden_field input field has been submitted.)
<?php
function my_plugin_options_page() {
if( isset( $_POST['my_plugin_hidden_field_submitted'] ) ) {
}
}
?>