save post (3 posts)

  1. STR-Ing
    Posted 5 years ago #

    hey guys !

    Am not really sure that i could post that question over here... so, forgive me if am wrong :)
    Moreover, i tried to search on the forum any solutions... without success or am blind ;-)

    Well, am looking for a hook that let me retrieve all the $_POST values when a post is edited/added... Here's my code :

    add_action('admin_menu', 'post_options_box');
    add_action('save_post ', 'str_save_post');
    function post_options_box()
    	add_meta_box('MetaBox', 'STRApp-It', 'str_draw_panel', 'post', 'side', 'high');
    	add_meta_box('MetaBox', 'STRApp-It', 'str_draw_panel', 'page', 'side', 'high');
    function str_draw_panel()
    	$target_content_values = array('key1' 				=> 'val1',
    								   'key2'		=> 'val2',
    								   'key3'				=> 'val3);
    	global $post;
    	$meta_values = get_post_meta($post->ID, '_target_content', false);
    	$action = 'add';
    	if (sizeof($meta_values) > 0) {
    		$action = 'update';
    		<input type="hidden" name="_target_content_action" value="<?php echo $action ?>" />
    			foreach ($target_content_values as $key => $value) {
    				$checked = '';
    				if($key == $meta_values[0])
    					$checked = 'checked';
    					<input type="radio" name="_target_content" value="<?php echo $key ?>" <?php echo $checked ?> /><?php echo $value ?><br />
    function str_save_post($post_id, $post)

    unfortunately, i see that when i click on the update button in the admin panel, nobody comes in my str_save_post function... Does anybody know what am doing wrong ??

    As you can see, am starting plugin developments on WordPress and am a lil bit lost ! ;-)

    Thanks for your help guys !

  2. STR-Ing
    Posted 5 years ago #

    My question is too dumb ? lol

  3. TAN77
    Posted 4 years ago #

    use add_action('save_post', 'str_save_post');
    without space in the name of action

Topic Closed

This topic has been closed to new replies.

About this Topic