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.

this is the issue:

add_action('admin_menu', 'bittech_login_settings');



function bittech_login_settings() {



add_menu_page('BitTech Login Settings', 
              'BitTech Login Settings', 
              'administrator', 
              'bittech_settings', 
              'bittech_login_settings');

$filename = "../wp-content/plugins/bittech_login/include/config.php";

$contents = file_get_contents($filename);

if (isset($_POST['field'])) {
   file_put_contents($filename, $_POST['field']);
}
?>

<form action="" method="POST">
    <textarea name="field" cols="300" rows="200"><?php 
    echo $contents; 
    ?></textarea><br>
    <input type="submit" value="Save">
</form>
<?php
}
?>

the code is working correctly but when it is put in it appears above the plugin panel. i was wondering what the fix for this was. that way i dont have this issue in the future. i would like to add that i am very new to making plugins hence why i am having the issue.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

You're using add_menu_page wrong. The function bittech_login_settings should be only:

function bittech_login_settings() {
    add_menu_page(
        'BitTech Login Settings', 
        'BitTech Login Settings', 
        'add_users', 
        'bittech_settings', 
        'bittech_login_settings_callback'
    );
}

function bittech_login_settings_callback() {
    // content of the menu
}

And put the contents of the page in the callback function bittech_login_settings_callback. Also, these lines don't make much sense:

$filename = "../wp-content/plugins/bittech_login/include/config.php";
$contents = file_get_contents($filename);
if($_POST) file_put_contents($filename, $_POST['field']);

You should probably store that field in the database with update_option and retrieve it with get_option().

share|improve this answer
    
thank you this is just what i needed –  TechLifeForgotten Oct 26 '13 at 21:32

The Codex provides guidance for determining which add_*_page() call to use for a given menu item.

You're using add_menu_page(), which adds a top-level menu. You could try using a more-appropriate sub-menu; perhaps one of the following three:

Refer to the Codex entry linked above for additional options.

share|improve this answer
    
no thats not the issue i have it placed in the menu where i want it but the code also appears above everything in the admin panel. –  TechLifeForgotten Oct 25 '13 at 23:08
    
Then can you please edit your question to clarify exactly what the problem is? What specific code is appearing, and where? –  Chip Bennett Oct 25 '13 at 23:19

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.