• Resolved dumsumguy

    (@dumsumguy)


    Two questions, any idea why this wouldn’t be saving properly. And, as an aside I have some debug data being emailed to myself, however, I keep getting emails that start with “no nonce or…” or “xxx <– the time”, how is it possible that something isn’t getting placed in front of the “xxx <– the time”

    add_action('save_post', 'sagecalendar_save_post');
    function sagecalendar_save_post($post_id){
    
    	// verify this came from the our screen and with proper authorization,
    	// because save_post can be triggered at other times
    
    	$mailmessage = time()."<--the time \r\n  POST VALS \r\n ".print_r($_POST, true). "\r\n";
    
    	if ( !wp_verify_nonce( $_POST['sagecal_nonce'], plugin_basename(__FILE__) )) {
    		$mailmessage = "No nonce or nonce failed value" . $_POST['sagecal_nonce'] ."\r\n". $mailmessage;
    		sagecal_sendmail($mailmessage); //just mailing myself values from this trying to figure out whats up
    		return $post_id;
    	}
    
    	if ('post' == $_POST['post_type']) {
    		if ( !current_user_can( 'edit_post', $post_id ))
    		$mailmessage =  "adfsadfasdfsafsadfsafasddfasafsdafascan't edit \r\n ". $_POST['sagecal_nonce'] ."\r\n". $mailmessage;
    		sagecal_sendmail($mailmessage);
    		return $post_id;
    	}
    
    	// OK, we're authenticated: we need to find and save the data
    	if (!isset($_POST['sagecal_add_event'])){
    		$mailmessage = "fas fasd ddf asdas fsa fsa fassagecal_add_event not set \r\n " . $_POST['sagecal_nonce'] ."\r\n" . $mailmessage;
    		sagecal_sendmail($mailmessage);
    		//post not included only save include status
    		if(!update_post_meta($post_id, '_sagecal_add_event', "0", true)){
    			add_post_meta($post_id, '_sagecal_add_event', "0", true);
    		}
    	}
    	else{
    			$mailmessage = "fasdf asdf saddfa sdf asdf sfdupdating \r\n " . $_POST['sagecal_nonce'] ."\r\n".$mailmessage;
    			sagecal_sendmail($mailmessage);
    			//post is to be included save all data
    			if(!update_post_meta($post_id, '_sagecal_add_event', "1", true)){
    				add_post_meta($post_id, '_sagecal_add_event', "1", true);
    			}
    
    			// building save data array
    			$sc_data_arr = array();
    
    			$sc_date = $_POST['sagecal_date_month'] . "/" . $_POST['sagecal_date_day'] . "/" . $_POST['sagecal_date_year'];
    			$sc_data_arr['date'] = $sc_date;
    
    			$sc_time = $_POST['sagecal_time_hour'] . ":" . $_POST['sagecal_time_minute'] . " " . $_POST['sagecal_time_am'];
    			$sc_data_arr['time'] = $sc_time;
    
    			$sc_data_arr['recurrence'] = $_POST['sagecal_recurrence'];
    
    			$sc_rdays = array();
    			$sc_rdays = $_POST['sagecal_days'];
    			$sc_data_arr['days'] = $sc_rdays;
    			//$sc_data_arr['datain'] = print_r($_POST, true);
    
    			//$sagecal_data = serialize($sc_data_arr);
    
    			if(!update_post_meta($post_id, '_sagecal_event_data', $sagecal_data, true)){
    			add_post_meta($post_id, '_sagecal_event_data', $sagecal_data, true);
    			}
    		}
    
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter dumsumguy

    (@dumsumguy)

    Sorry meant to remove the spam from the mailmessage= lines, sorry as you can tell I was a bit frustrated. Is there an edit option I am not seeing?

    Thread Starter dumsumguy

    (@dumsumguy)

    Admin please delete this thread… it’s posted in wrong place, has dumb mistakes, and needs to be otherwise destroyed.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Need help with a save action’ is closed to new replies.