Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have this php Code to make a option page that activate a function if the user set "active" and turn off the function, if the user set "Not active".

<?php
add_action('admin_menu', 'custom');
function custom() {
add_menu_page('settings', 'settings', '8', 'custom', 'customfunc');
}
function customfunc(){
$wpp_rg = get_option('wpp_rg');
if ($_POST['submit']):
update_option('wpp_rg',$_POST['wpp_rg']);
endif;
?>
<div class="wrap">
<form action="" method="post">
<table width="70%" border="0" cellspacing="5" cellpadding="5">
<tr>
        <th scope="row">test mode :</th>
        <td><p>
         <label>
                <input name="wpp_rg" type="radio" value="1" id="RadioGroup1_0" <?php echo ($wpp_rg==1 ? 'checked="checked"' : '') ?> />
                active</label>
         <br />
         <label>
                <input name="wpp_rg" type="radio" value="2" id="RadioGroup1_1" <?php echo ($wpp_rg==2 ? 'checked="checked"' : '') ?>/>
                not active</label>
         <br />
        </p></td>
</tr>

<tr>
        <th></th>
        <td><input type="submit" name="wpp_submit" value="save" class="button" /></td>
</tr>
</table>
</form>
</div>
<?php
}

$wpp_rg = get_option('wpp_rg');



/******************** IF1 ***********************/

if ($wpp_rg==1) {

echo "Active";



}
if ($wpp_rg==2) {

echo "Not Active";

}
/******************** IF1 ***********************/


?>

But the problem is that, the html radios are not working ! when i click "not active " and save, nothing happen !

What is the problem ? ?

share|improve this question
    
Isn't it supposed to be if($_POST['wpp_submit'])? –  gdaniel Mar 7 at 21:32
    
@gdaniel not work again :( –  user3394468 Mar 7 at 21:38
    
You really need to sanitize your input and use nonces, you're just asking to get hit by a cross site scripting attack. –  Andrew Bartel Mar 7 at 21:59
    
You really need to be using the Settings API. –  vancoder Mar 7 at 22:36
    
@vancoder That too. –  Andrew Bartel Mar 7 at 22:49

1 Answer 1

I believe the problem could be with your add_menu_page() function.

You have your 3rd parameter set as '8' and that is a deprecated use of that particular parameter (capability). See:

http://codex.wordpress.org/Function_Reference/add_menu_page

and

http://codex.wordpress.org/User_Levels

You should try changing that to the correct string representation.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.