WordPress.org

Ready to get started?Download WordPress

Forums

Q from a Noob. "You do not have sufficient permissions to access this page." (2 posts)

  1. dandeibert
    Member
    Posted 4 years ago #

    First, I am a plug-in noob so please speak slowly. :-)

    About a year ago, I developed a small plug-in that would allow me to put a "Breaking News Now" kind of thing on the home page of my WP blog. Kind of like you see on CNN or Fox... red box at the top of the screen. It writes the text, a link, and a start and end time to the wordpress db. When the page loads, it checks to see if there is an active breaking news story, based on the start and end times, and if so, displays it.

    It was working just fine on a couple of my sites... then I upgraded wordpress on 2 of those sites about a year ago and it hasn't worked on either since. (pretty sure it was 2.8.1 when it broke)

    When I go to the admin section in WP, I can see and get to the plug in options menu I created. I can get to the page where I enter my data, but when I press the submit button, I get this error:

    You do not have sufficient permissions to access this page.

    Based on the research I've done, I think it has something to do with plugin registration and this is a concept that I'm just not wrapping my head around.

    I'd be happy to drop a 20 into the amazon acct or paypal or something if someone has a moment to look at the plugin and explain to me where the registration breakdown is. I have honestly spent 20+ hours trying to figure this out. :-(

    The plugin is here: http://www.dandeibert.com/hapnow.zip

    Also, as I wasn't intending this to be a published plugin (at least right away) I created the db table by hand... and their creation is not scripted into the plugin. I'm certain that form to db function is working and that is not where the problem is.

    Thanks in advance. Again... very noob here so if there is anything else needed to provide, please let me know.

  2. dandeibert
    Member
    Posted 4 years ago #

    hapening_now.php

    <?php
    		/*
    		Plugin Name: Happening Now Headline Generator
    		Plugin URI: http://www.dspotblog.com
    		Description: Custom Plugin for The D-Spot Blog
    		Author: Dan Deibert
    		Version: 1.0
    		Author URI: http://www.dspotblog.com
    		*/
    
    		function happening_now() {
    			include('happening_now_data_management.php');
    			}
    
    function happening_now_actions() {
        	add_options_page("Happening Now", "Happening Now", 1, "Happening Now", "happening_now");
    		}
    
    		add_action('admin_menu', 'happening_now_actions');
    		?>

    happening_now_data_management.php

    <?php
    global $wpdb;
    require_once('wp-load.php');
    
    ?>
    
    <?php
    		if($_POST['oscimp_hidden'] == 'Y') {
    			//Form data sent
    
         $hap_now_text = $_POST['haptext'];
    	$link_now_text = $_POST['linktext'];
    	$start_date = $_POST['sdate'];
    	$end_date = $_POST['edate'];
    $wpdb->query("UPDATE wp_hapnow SET the_text='$hap_now_text', the_link='$link_now_text', start = '$start_date', end = '$end_date'  WHERE wp_hapnow.id =1 ") ;
    
    		} else {
    			//Normal page display
    
    		}
    
    	/* If your time GMT+2 then your offset is time()+7200 .. if your time is GMT-2 then your offset is time()-7200 and so on.  Multiply
    the number of hours for your offset by 3600 */
    	$offset = time()-18000;
    	$offset2 = time()-10800;
    
    		$hapnowtext = $wpdb->get_var("SELECT the_text FROM wp_hapnow");
    		$linktext = $wpdb->get_var("SELECT the_link FROM wp_hapnow");
    		$startdate = $wpdb->get_var("SELECT start FROM wp_hapnow");
    		$enddate = $wpdb->get_var("SELECT end FROM wp_hapnow");
    		$curtime = gmdate("Y-m-d H:i:s", $offset);
    		$proj_endtime = gmdate("Y-m-d H:i:s", $offset2); 	
    
    	?>
    
    <div class="wrap">
    			<?php    echo "<h2>" . __( 'D-Spot Happening Now Controller', 'oscimp_trdom' ) . "</h2>"; ?>
    
    			<form name="happening_now_form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=<?php echo plugin_basename(__FILE__); ?>&updated=true">
    				<input type="hidden" name="oscimp_hidden" value="Y">
    				<?php    echo "<h4>" . __( 'Happening Now Settings', 'oscimp_trdom' ) . "</h4>"; ?>
    				<p><?php _e("Current Settings: " ); ?><br />Start Time: <?php echo $startdate ?> <br /> End Time: <?php echo $enddate ?></p>
    				<p><?php _e("Text for Display: " ); ?><br /><textarea name="haptext"  rows="2" cols="70"><?php echo $hapnowtext; ?></textarea></p>
    				<p><?php _e("Link for headline:(with http) " ); ?><br /><textarea name="linktext"  rows="1" cols="70"><?php echo $linktext; ?></textarea></p>
    				<p><?php _e("Start Time" ); ?>  <input type="text" name="sdate" size="25" value="<?php echo $curtime; ?>"></p>
    				<p><?php _e("End Time" ); ?>    <input type="text" name="edate" size="25" value="<?php echo $proj_endtime; ?>"></p>
    
    				<p class="submit">
    				<input type="submit" name="Submit" value="<?php _e('Update Options', 'oscimp_trdom' ) ?>" />
    				</p>
    			</form>
    		</div>

Topic Closed

This topic has been closed to new replies.

About this Topic