• David Gard

    (@duck_boy)


    Hey all,

    I am trying to write my first plugin but I am having trouble getting the values to save, so was wondering if someone could take a look at my code below and let me know if I am doing something wrong?

    add_action('admin_menu', 'dcd_plugin_menu');
    add_action('admin_init', 'dyne_office_details_options_init' );
    
    function dyne_office_details_options_init(){
    	register_setting('dyne_offices_options', 'dyne_offices_link');
    }
    
    function dcd_plugin_menu() {
    	add_options_page('Dyne Drewett LLP Contact Details', 'Office Details', 8, 'dyne-contact-details', 'dyne_office_details_options_page');
    }
    
    function dyne_office_details_options_page() {
    	add_option('dyne_offices_link', $offices);
    ?>
    	<div id="howto-metaboxes-general" class="wrap">
    		<?screen_icon('options-general')?>
    		<h2>Dyne Drewett LLP Office Details</h2>
    		<!-- Start of Left Aligned Column -->
    		<form method="post" action="options.php">
    			<div class="left_side">
    				<?settings_fields('dyne_offices_options')?>
    				<?$offices = get_option('dyne_offices_link')?>
    				<?$count1 = count($offices);?>
    				<!-- Offices Management -->
    				<div class="metabox-holder">
    					<div class="postbox">
    					<h3 class="hndle"><span>Offices Management</span></h3>
    						<div class="inside">
    							<table class="form-table">
    								<tr valign="top">
    									<th scope="row">Add an office</th>
    									<td><input type="text" tabindex="10" name="dyne_offices_link[<?echo $count1?>]" value="" /></td>
    									<th scope="row">Current offices</th>
    									<td> { Will out put the offices here }</td>
    								</tr>
    							</table>
    						</div>
    					</div>
    				</div>
    				<!-- End of Offices Management -->
    				<!-- Submit Button -->
    				<p class="submit">
    					<input type="submit" tabindex="40" class="button-primary" value="<?_e('Save Changes')?>" />
    				</p>
    				<!-- End of Submit Button -->
    			</div>
    		</form>
    	</div>
    	<!-- End of Left Aligned Column -->
    <?php
    }
  • The topic ‘Plugin value not saving’ is closed to new replies.