• Scampi

    (@scampi)


    Hello

    Long time reader, first time caller.
    I am getting the following warning when saving posts, customs posts in the admin, it has to with this line: add_action('save_post', 'save_details');

    The error I get is:Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘save_details’ not found or invalid function name in /home/mccrudde/public_html/newsite/wp-includes/plugin.php on line 406

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘save_details’ not found or invalid function name in /home/mccrudde/public_html/newsite/wp-includes/plugin.php on line 406

    Warning: Cannot modify header information – headers already sent by (output started at /home/mccrudde/public_html/newsite/wp-includes/plugin.php:406) in /home/mccrudde/public_html/newsite/wp-includes/pluggable.php on line 876

    Now the URL rewrite works perfectly, but, updating the post give the error warning and noting else, however changes to the post content are saved. Also I don’t get this error on my local host just online ‘both V3.5.1″

    I have pasted below the full CPT function code.

    add_action('init', 'trainingcourses');
    
    function trainingcourses() {
    
         register_taxonomy(
            'coursesector',
            'trainingcourses',
            array(
                'label' => 'Training Sectors',
                'singular_label' => 'Type',
                'hierarchical' => true,
                'query_var' => true,
                'rewrite' => array('slug' => 'training'),
            )
        );
    
        $labels = array(
            'name' => _x('Training Courses', 'post type general name'),
            'singular_name' => _x('Sector', 'post type singular name')
        );
    
        $args = array(
            'labels' => $labels,
            'public' => true,
            'publicly_queryable' => true,
            'show_ui' => true,
            'query_var' => true,
            'capability_type' => 'post',
            'hierarchical' => false,
            'menu_position' => 6,
            'supports' => array('title','editor','thumbnail', 'excerpt'),
            'rewrite' => array(
                //'slug' => 'training',
                'slug' => 'training/%coursesector%',
                'with_front' => false
            ),
            'has_archive' => 'training'
        ); 
    
        register_post_type( 'trainingcourses' , $args );
        flush_rewrite_rules();
    }
    
    add_action('save_post', 'save_details');
    
    add_filter('post_type_link', 'training_permalink_structure', 10, 4);
    function training_permalink_structure($post_link, $post, $leavename, $sample)
    {
        if ( false !== strpos( $post_link, '%coursesector%' ) ) {
            $coursesector_term = get_the_terms( $post->ID, 'coursesector' );
            $post_link = str_replace( '%coursesector%', array_pop( $coursesector_term )->slug, $post_link );
        }
        return $post_link;
    }

    this problem on occurs witin the admin, as I say the site front-end works fine. but I can’t hand over to client with the error screen. I have looked for hours for a solution, but I’m not a coder so am struggling, any help gratefully received.

The topic ‘function 'save_details' not found, Warning’ is closed to new replies.