Skip to:

Re: Problem using a form in a plugin

Sam Bauers


You are missing the API hooks, and you have to be a bit more specific about your forms submit name to distinguish it from other plugins.

The code below is at least a step closer, notice the change to the name of the submit button and to the if conditional in the update_bbportal function. The specified action allows that function to be called when the admin header is loaded.

You will also have to pull the values you insert into the options back out again to re-populate the form on the same page.

// Add action for the admin area to process the form

// Show form
function bbportal_form() {
<h2><?php _e('Portal Management'); ?></h2>
<h3><?php _e('Portal settings'); ?></h3>
<form action="" method="post">
<tr><th scope="row"><label for="forum_id"><?php _e('Where do you want to pull the topics from?'); ?></th>
<td><?php forum_dropdown(); ?></label></td>
<tr><th scope="row"><?php _e('Number of topics on the portal:'); ?></th>
<td><input type="text" name="number_of_topics" id="number_of_topics" /></td>
<p class="submit alignleft"><input name="submitPortal" type="submit" value="<?php _e('Submit'); ?>" />


// Update portal
function update_bbportal() {
if (isset($_POST['submitPortal'])) {
bb_update_option( 'pforum_id', $_POST['forum_id'] );
bb_update_option( 'number_of_topics', $_POST['number_of_topics'] );

Well, at least that is one way to do it.

Skip to toolbar