Only administrators can update (own plugin)
-
Hi there.
I’m working on a simple plugin so users can update to database. Nothing advanced really. It works great to update for administrators but not any other users. I want everyone to be alble to update this regarding of user-level. What am I doing wrong?
The “error” I get when trying to post with other accounts that’s not admin i get message: “Cheatin, uh?” I guess it’s something with the prevelieges. My complete code can be found below:
function ochdonk_recept() { echo get_option(‘ochdonk_recept_data’); } /* Runs when plugin is activated */ register_activation_hook(__FILE__,'ochdonk_recept_install'); /* Runs on plugin deactivation*/ register_deactivation_hook( __FILE__, 'ochdonk_recept_remove' ); function ochdonk_recept_install() { /* Creates new database field */ add_option("ochdonk_recept_data", 'Default', '', 'yes'); } function ochdonk_recept_remove() { /* Deletes the database field */ delete_option('ochdonk_recept_data'); } /* Call the html code */ add_action('admin_menu', 'ochdonk_recept_admin_menu'); function ochdonk_recept_admin_menu() { //add_options_page('&D?nk recept', '&D?nk recept', 'administrator', add_posts_page('&D?nk recept', '&D?nk recept', 'read', 'ochdonk-recept', 'ochdonk_recept_html_page'); } function ochdonk_recept_html_page() { ?> <div class="wrap"> <?php screen_icon(); ?> <h2>&D?nk recept</h2> <form method="post" action="options.php"> <?php wp_nonce_field('update-options'); ?> <table> <tr valign="top"> <td> <textarea name="ochdonk_recept_data" type="text" id="ochdonk_recept_data" rows="50" cols="150"><?php echo get_option('ochdonk_recept_data'); ?></textarea> </td> </tr> </table> <input type="hidden" name="action" value="update" /> <input type="hidden" name="page_options" value="ochdonk_recept_data" /> <p> <input type="submit" value="<?php _e('Save Changes') ?>" /> </p> </form> </div> <?php } ?>
- The topic ‘Only administrators can update (own plugin)’ is closed to new replies.