Support

Account

Home Forums Front-end Issues front end form issues

Solving

front end form issues

  • on the following page http://dev.rgbdesignuk.com/create-memorial/?action=create_memorial&status=new i get the following fault every time i try to save my form plase advise

    Warning: array_merge(): Argument #2 is not an array in /home/********/public_html/dev/wp-includes/post.php on line 3013

    Warning: Cannot modify header information – headers already sent by (output started at /home/********/public_html/dev/wp-includes/post.php:3013) in /home/********/public_html/dev/wp-includes/pluggable.php on line 896

  • can any one help with this I’m really stuck

  • Hi @jadejd

    It sounds like you are passing a non array parameter to the acf_form function.
    What does your code look like for this function?

    Thanks
    E

  • for the form its

    the code bellow

    <?php
    /**
     * Template Name:create memorial Template
     *
     * @package WooFramework
     * @subpackage Template
     */
    
    acf_form_head();
     
    get_header(); ?>
    
        <!-- #content Starts -->
    <?php woo_content_before(); ?>
        <div id="content" class="col-full">
        
        <div id="main-sidebar-container">    
    
                <!-- #main Starts -->
                <?php woo_main_before(); ?>        
    
     
    	<div id="primary">
    		<div id="content" role="main">
     
    			<?php the_post(); ?>
     
    			<?php acf_form( $options ); ?>
     
    		</div><!-- #content -->
    	</div><!-- #primary -->
     
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
                       
    <?php
    woo_loop_before();
    if (have_posts()) { $count = 0;
    while (have_posts()) { the_post(); $count++;
    woo_get_template_part( 'content', 'page' ); // Get the page content template file, contextually.
    }
    }
    woo_loop_after();
    ?>     
                </section><!-- /#main -->
                <?php woo_main_after(); ?>
        
                <?php get_sidebar(); ?>
    
    </div><!-- /#main-sidebar-container -->         
    
    <?php get_sidebar( 'alt' ); ?>
    
        </div><!-- /#content -->
    <?php woo_content_after(); ?>
    
    <?php get_footer(); ?>

    the single memorial code

    <?php
    /**
     * Template Name:create memorial Template
     *
     * @package WooFramework
     * @subpackage Template
     */
    the_post();
    
    $template = get_field('template', $post->ID);
    if (empty($template)) {
        $template = 'standard';
    }
    $template_dir = get_stylesheet_directory() . '/memorials';
    $template_uri = get_stylesheet_directory_uri() . '/memorials';
    $templateFile = $template_dir . '/' . strtolower($template) . '.php';
    if (file_exists($templateFile)) {
        include($templateFile);
    }
    

    and the custom post type plugin

    ?php
    
    /*
      Plugin Name: Lvd4Evr - Memorial Custom Post Type
      Plugin URI:
      Description:
      Version: 1.0.0
      Author: Kathryn Reeve
      Author URI: http://BinaryKitten.com
      License: GPLv2
     */
    
           
    
    class j20_lovedforever_memorial
    {
    
        public function __construct()
        {
            add_action('init', array($this, 'create_post_type'), 0);
            $this->addAcf();
        }
    
        function create_post_type()
        {
    
            $labels = array(
                'name' => _x('Memorials', 'Post Type General Name', 'text_domain'),
                'singular_name' => _x('Memorial', 'Post Type Singular Name', 'text_domain'),
                'menu_name' => __('Memorial', 'text_domain'),
                'parent_item_colon' => __('Parent Memorial:', 'text_domain'),
                'all_items' => __('All Memorials', 'text_domain'),
                'view_item' => __('View Memorial', 'text_domain'),
                'add_new_item' => __('Add New Memorial', 'text_domain'),
                'add_new' => __('Add New Memorial', 'text_domain'),
                'edit_item' => __('Edit Memorial', 'text_domain'),
                'update_item' => __('Update Memorial', 'text_domain'),
                'search_items' => __('Search Memorials', 'text_domain'),
                'not_found' => __('No Memorial Found', 'text_domain'),
                'not_found_in_trash' => __('Memorial not found in Trash', 'text_domain'),
            );
            $rewrite = array(
                'slug' => 'memorial',
                'with_front' => true,
                'pages' => false,
                'feeds' => false,
            );
            $args = array(
                'label' => __('memorial', 'text_domain'),
                'description' => __('Memorial Pages', 'text_domain'),
                'labels' => $labels,
                'supports' => array('title', 'author','comments'),
                'taxonomies' => array('category', 'memorial'),
                'hierarchical' => false,
                'public' => true,
                'show_ui' => true,
                'show_in_menu' => true,
                'show_in_nav_menus' => true,
                'show_in_admin_bar' => true,
                'menu_position' => 20,
                'menu_icon' => '',
                'can_export' => true,
                'has_archive' => true,
                'exclude_from_search' => false,
                'publicly_queryable' => true,
                'rewrite' => $rewrite,
                'capability_type' => 'page',
            );
    
            register_post_type('memorial', $args);
    
            register_post_type( 'tribute',
                array(
                    'labels' => array(
                        'name' => __( 'Tributes' ),
                        'singular_name' => __( 'tribute' )
                    ),
                    'public' => true,
                    'has_archive' => true,
                    'rewrite' => array('slug' => 'tribute'),
                )
            );
    
            register_post_type( 'stories',
                array(
                    'labels' => array(
                        'name' => __( 'stories' ),
                        'singular_name' => __( 'stories' )
                    ),
                    'public' => true,
                    'has_archive' => true,
                    'rewrite' => array('slug' => 'stories'),
                )
            );
    
            register_post_type( '_user_video',
                array(
                    'labels' => array(
                        'name' => __( 'Video' ),
                        'singular_name' => __( 'video' )
                    ),
                    'public' => true,
                    'has_archive' => true,
                    'rewrite' => array('slug' => 'video'),
                )
            );
        }
    
        public function addAcf() {
         //   include plugin_dir_path(__FILE__) . DIRECTORY_SEPARATOR . 'acf.php';
        }
    
    }
    
    new j20_lovedforever_memorial();
    
    function my_pre_save_post( $post_id )
    {
        
        
        
        // Create a new post
        $post = array(
            'post_status'  => 'publish' ,
            'post_title'  =>  $_POST['title'],
            'post_type'  => 'memorial' ,
        );  
      
      
        if(get_post($id)) {
            $post_id = wp_update_post( get_post($post_id) );  
        } else {
            $post_id = wp_insert_post( $post );  
        };
        // insert the post
       
       
    
        // update $_POST['return']
        $_POST['return'] = add_query_arg( array('post_id' => $post_id), $_POST['return'] );    
     
        // return the new ID
        return $post_id;
    }
    
     
    add_filter('acf/pre_save_post' , 'my_pre_save_post' );
    
    add_action('init', 'process_choose_template');
    
    function process_choose_template(){
     if(isset($_POST['choose-template'])) {
        $template = $_POST['template'];
        $post_id = $_POST['post_id'];
        add_post_meta(  $post_id , 'memorial_template', $template, true ) || update_post_meta(  $post_id , 'memorial_template', $template );
        wp_redirect( get_permalink($post_id) ); 
        exit(); 
     }
    }
    
    function memorial_save_post_class_meta($post_id, $post ) {
        if (get_post_type( $post ) == 'memorial'){
            $template = $_POST['template'];
            add_post_meta(  $post_id , 'memorial_template', $template, true ) || update_post_meta(  $post_id , 'memorial_template', $template );
    
        }
    }
    
    /* Fire our meta box setup function on the post editor screen. */
    
    //Meta Box 
    /* Meta box setup function. */
    function memorial_post_meta_boxes_setup() {
    
        /* Add meta boxes on the 'add_meta_boxes' hook. */
        add_action( 'add_meta_boxes', 'memorial_add_post_meta_boxes' );
    
        /* Save post meta on the 'save_post' hook. */
        add_action( 'save_post', 'memorial_save_post_class_meta', 10, 2 );
    }
    
    /* Create one or more meta boxes to be displayed on the post editor screen. */
    function memorial_add_post_meta_boxes() {
    
        add_meta_box(
            'memorial-post-class',          // Unique ID
            'Templates',      // Title
            'memorial_post_class_meta_box',     // Callback function
            'memorial',                 // Admin page (or post type)
            'side',                 // Context
            'default'                   // Priority
        );
    }
    
    function memorial_post_class_meta_box( $object, $box ) { ?>
        <?php $value = get_post_meta( $object->ID, 'memorial_template', true )?>
    
        <div>
            <label for=''>Template 1</label>
            <div class='chose-template-input'><input type='radio' name='template' value='1'  <?php echo ($value  == '1'|| $value  == '' ? 'checked="checked"' : '');?>></div>
        </div>
         <div>
            <label for=''>Template 2</label>
            <div class='chose-template-input'><input type='radio' name='template' value='2' <?php echo ($value  == '2' ? 'checked="checked"' : '');?>></div>
        </div>
         <div>
           <label for=''>Template 3</label>
            <div class='chose-template-input'><input type='radio' name='template' value='3' <?php echo ($value  == '3' ? 'checked="checked"' : '');?>></div>
        </div>
                     
                            
     <?php }            
    
    add_action( 'load-post.php', 'memorial_post_meta_boxes_setup' );
    add_action( 'load-post-new.php', 'memorial_post_meta_boxes_setup' );
    
        // Disable Admin Bar for everyone but administrators
    if (!function_exists('df_disable_admin_bar')) {
    
        function df_disable_admin_bar() {
            
            if (!current_user_can('manage_options')) {
            
                // for the admin page
                remove_action('admin_footer', 'wp_admin_bar_render', 1000);
                // for the front-end
                remove_action('wp_footer', 'wp_admin_bar_render', 1000);
                
                // css override for the admin page
                function remove_admin_bar_style_backend() { 
                    echo '<style>body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }</style>';
                }     
                add_filter('admin_head','remove_admin_bar_style_backend');
                
                // css override for the frontend
                function remove_admin_bar_style_frontend() {
                    echo '<style type="text/css" media="screen">
                    html { margin-top: 0px !important; }
                    * html body { margin-top: 0px !important; }
                    </style>';
                }
                add_filter('wp_head','remove_admin_bar_style_frontend', 99);
                
            }
        }
    }
    
    //add_action('init','df_disable_admin_bar');
    
    add_action('pre_get_posts','ml_restrict_media_library');
    
    function ml_restrict_media_library( $wp_query_obj ) {
        global $current_user, $pagenow;
        if( !is_a( $current_user, 'WP_User') )
        return;
        if( 'admin-ajax.php' != $pagenow || $_REQUEST['action'] != 'query-attachments' )
        return;
        if( !current_user_can('manage_media_library') )
        $wp_query_obj->set('author', $current_user->ID );
        return;
    }
    
    function tribute() {
      
        if(isset($_POST['submit_tribute'])){
              global $current_user;
              get_currentuserinfo();
            $post = $_POST['post_id'];
           $new_post = array(
                    'post_title' => $current_user->display_name,
                    'post_content' => $_POST['copy'],
                    'post_status' => 'publish',
                    'post_date' => date('Y-m-d H:i:s'),
                    'post_author' => $current_user->ID,
                    'post_type' => 'tribute',
                    'post_category' => array(0)
                    );
    
                   
            $post_id = wp_insert_post($new_post);
                add_post_meta(  $post_id , 'memorial_id', $post, true ) || update_post_meta(  $post_id , 'memorial_id', $post );
              wp_redirect( get_permalink($post) ); 
            exit(); 
        }
     
    }
    add_action('init','tribute');
    
    function stories() {
      
        if(isset($_POST['submit_Stories'])){
              global $current_user;
              get_currentuserinfo();
            $post = $_POST['post_id'];
           $new_post = array(
                    'post_title' => $current_user->display_name,
                    'post_content' => $_POST['copy'],
                    'post_status' => 'publish',
                    'post_date' => date('Y-m-d H:i:s'),
                    'post_author' => $current_user->ID,
                    'post_type' => 'stories',
                    'post_category' => array(0)
                    );
    
                   
            $post_id = wp_insert_post($new_post);
                add_post_meta(  $post_id , 'memorial_id', $post, true ) || update_post_meta(  $post_id , 'memorial_id', $post );
              wp_redirect( get_permalink($post) ); 
            exit(); 
        }
     
    }
    add_action('init','stories');
    
    function video() {
    
        if(isset($_POST['submit_video'])){
            global $current_user;
              get_currentuserinfo();
            $post = $_POST['post_id'];
           $new_post = array(
                    'post_title' => $current_user->display_name." ".$_POST['embed'],
                    'post_content' => $_POST['embed'],
                    'post_status' => 'publish',
                    'post_date' => date('Y-m-d H:i:s'),
                    'post_author' => $current_user->ID,
                    'post_type' => '_user_video',
                    'post_category' => array(0)
                    );
    
            $info = video_image($_POST['embed']);      
            $post_id = wp_insert_post($new_post);;
            update_field( 'video', $_POST['embed'], $post_id  );  
            update_field('image_url', $info, $post_id  );  
            add_post_meta(  $post_id , 'memorial_id', $post, true ) || update_post_meta(  $post_id , 'memorial_id', $post );  
            wp_redirect( get_permalink($post) ); 
            
        }
     
    }
    
    add_action('init','video');
    
    function video_image($url){
        $image_url = parse_url('http://'.$url);
        if($image_url['host'] == 'www.youtube.com' || $image_url['host'] == 'youtube.com'){
            $array = explode("&", $image_url['query']);
            return "http://img.youtube.com/vi/".substr($array[0], 2)."/0.jpg";
        } else if($image_url['host'] == 'www.vimeo.com' || $image_url['host'] == 'vimeo.com'){
            $hash = unserialize(file_get_contents("http://vimeo.com/api/v2/video/".substr($image_url['path'], 1).".php"));
            return $hash[0]["thumbnail_small"];
        }
    }

    I hope this helps if you need any more info i can provide this

  • Hi @jadejd

    Your code: <?php acf_form( $options ); ?> contains a parameter of $options, but this variable is never defined.

    A variable that has not been defined cannot be passed into a function. You must either define $options as a valid array (please read the acf_form documentation) or don’t pass the variable at all.

    Thanks
    E

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘front end form issues’ is closed to new replies.