Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter smarie33

    (@smarie33)

    thank you for your reply. i could not get the code from that link to work with the media uploader. everywhere i look for this solution they all create a new upload form. i can’t use that code because i can’t grab the uploaded image url from the media uploader without javascript and that creates a whole bunch of other problems for me, (i want the media uploader to handle all the image processing anyway). but i finally found my solution here: https://www.ads-software.com/support/topic/wp_editor-media-upload?replies=6

    now the code from my theme page where the post is processed looks like this

    <?php
     //information sent from the response pages that have the template Response Template page
    get_currentuserinfo();
    $loggedInNow = $current_user->ID;
    $response = wp_insert_post(array(
    'ID' => $_POST['postempty'],
    'comment_status' => 'closed',
    'post_title' => $_POST['postTitle'],
    'post_content' => $_POST['responsesubmit'],
    'post_author' => $loggedInNow,
    'post_status' => 'publish',
    'post_type' => 'post'
    );
    
     global $post_ID;
     $post_ID = $emptynew;
    ?>

    i added enctype=”multipart/form-data” in my form with wp_editor in it for good measure. so simple, i wish this was documented, did not come across it in google easily.

    Thread Starter smarie33

    (@smarie33)

    So I looked up my server logs to see what the problem was. Looks like I needed to include the taxonomy.php not the pluggable.php. I had to include a lot of different wordpress pages by the end of this plugin. And you can find what php page each function is called from in the wordpress documentation at the bottom of the page of the function you are reading about. I guess moral of the story is: a 500 error = look at your server logs! AAAHHHH noobs…

    I also found out that the update_post_meta function needs to have double quotes in its parameters… weird that I’m not forced to use double quotes anywhere else.

    so this:

    update_post_meta($post_id, "_wp_page_template", "page-response.php");

    NOT this:

    update_post_meta($post_id, '_wp_page_template', 'page-response.php');

    So I figured out the problem by comparing it to a template page I created a long time ago that worked when I added it dynamically. Turns out that the description of the template has to be between its own php brackets, then the header!

    CORRECT:

    <?php
    /**
     * Template Name: Thank You
     * Description: A Page Template that adds the code for the editor to process the posts
     */
     ?>
    
    <?php get_header(); ?>

    INCORRECT

    <?php
    /**
     * Template Name: Thank You
     * Description: A Page Template that adds the code for the editor to process the posts
     */
    
     get_header(); ?>

    even though the “incorrect” way works just fine if you’re creating a template!

    sorry, for the

    global $wp_query;
    $wp_query->is_single = false;

    I was trying to use shawmutsteve’s suggestion, but I don’t really know where to put it or how to implement it. The same things happen wether that code is there or not.

    sorry to revamp an old question, but I am also having trouble attaching a theme to a created page. so this is my code

    get_currentuserinfo();
    $loggedInNow = $current_user->ID;
    global $wp_query;
    $wp_query->is_single = false;
    $post_id = wp_insert_post(array(
    	'comment_status' => 'closed',
    	'post_title' => $_POST['passcattopostfunction'],
    	'post_content' => $_POST['contentsubmit'],
    	'post_author' => $loggedInNow,
    	'post_status' => 'publish',
    	'post_type' => 'page'
    	)
    );
    add_post_meta($post_id,' _wp_page_template', 'page-response.php', false);

    Everything works correctly except for the adding the template. I look in the database when I create a page and the meta data actually says ‘page-response.php’, but when I go to the backend I see under the Page Attributes that the template is still ‘Default Template’, then I navigate to the page and it’s definitely the default template. So I go and manually change the template to ‘Response Template’ (that’s what page-response.php is) and then it updates and the page is definitely under the theme that I want. I go to the database and I see a second entry for the page id in the wp_postmeta table with a new meta id. This happens with add_post_meta AND update_post_meta. I’m following wordpress documentation exactly, so I don’t know what it could be.

    Any help would be appreciated!

    Thread Starter smarie33

    (@smarie33)

    Maybe you can’t use wordpress functions inside of a plugin with out an add_action hook? Can someone verify that? Or maybe I’m missing a php file i need to include? Please help.

Viewing 7 replies - 1 through 7 (of 7 total)