Forum Replies Created

Viewing 15 replies - 76 through 90 (of 213 total)
  • Plugin Author aryanduntley

    (@dunar21)

    Send me your csv

    Plugin Author aryanduntley

    (@dunar21)

    Your welcome, and thank you.

    Plugin Author aryanduntley

    (@dunar21)

    send me your csv file, and a screen shot of the headers list displayed when you choose a form. [email protected]

    Plugin Author aryanduntley

    (@dunar21)

    Not exactly sure what you are asking here. If you have a form that has certain fields, you need to identify those fields in the headers section of the csv file, then if you wish to change the form later on, you can do so, just as long as the headers in the csv file reflect the changes.

    Plugin Author aryanduntley

    (@dunar21)

    You cannot use the gravity forms export field csv file. When I designed this plugin I did not design it with that format in mind. I probably should have, but I did not. I no longer update this plugin, but if I do in the future by some off-chance, then I will look into it. In order to correctly import to your form, you have to follow the naming structure as shown in the valid fields area. This is the actual string value that you assigned to that field when creating the form. It is correct and valid to expect the csv header format in this manner.

    Plugin Author aryanduntley

    (@dunar21)

    It is working fine. It is possible that you are missing the js folder and files. Please deactivate and delete the version you have now and re-install the plugin. All files should be present and it should work. There may have been a time during an update where I incorrectly or partially updated the repository and you just happened to get that version.

    Plugin Author aryanduntley

    (@dunar21)

    Plugin Author aryanduntley

    (@dunar21)

    Yeah, it seems to have broken with the new WP update. I no longer maintain this plugin, but I’ll look into it briefly.

    Plugin Author aryanduntley

    (@dunar21)

    I have a file for you to replace one that is there. You will have to have access to ftp or ssh to swap files. It will allow you to upload html, but you will have to make sure your csv file is properly escaped inside of the html fields. Email me [email protected] and I will send you the file.

    Plugin Author aryanduntley

    (@dunar21)

    Yeah, you’re likely not structuring your csv file correctly. Send me a copy of it and I’ll take a look. Also send a screenshot of the list of headers the plugin gives you right after you choose a form.

    correct

    Ok Ryan, I see that you hooked into pre insert:

    add_filter( 'json_pre_insert_post', array( $wp_json_media, 'preinsert_check' ), 10, 3 );

    in plugin.php. So after creating the media and getting the id, instead of adding a post_meta key of _thumbnail_id, you would just add the param “featured_image” with the previously returned media attachment ID and it will filter through to the set_post_thumbnail method.

    There are three ways as I see it. You can hook into the edit post method in one of two ways (json_insert_post or json_pre_insert_post), or you can extend the api with WP_JSON_CustomPostType or WP_JSON_Posts. Extending using posts, see class json media. Extending using custom post type see json page.

    The downfall to using json_insert_post is that a new record (revision) of the post will be created and with a lot of comments, this may be undesirable. The downside to json_pre_insert_post is that you would have to return a WP Error object. That can be hacked by returning something like : return new WP_Error( 'json_comment_created', __('Your Comment ID ' . $commentID . 'Was Created.'), array( 'status' => 201));

    http://codex.ww.wp.xz.cn/Function_Reference/wp_insert_comment

    function put_a_comment($post, $data, $update){
     if($update){
      /*MAKE SURE COMMENT IS NOT SPAM, IS VALID, IS ESCAPED, WHATEVER*/
      $data = array(
         'comment_post_ID' => $post["ID"],
         {RESTOF_NEEDED_COMMENT_DATA}
      );
      $cmid = wp_insert_comment($data);
     }
    }
    
    add_action( 'json_insert_post', 'put_a_comment', 10, 3);
    
    function put_a_comment_errr($true, $post, $data, $update){
     if($update){
      /*MAKE SURE COMMENT IS NOT SPAM, IS VALID, IS ESCAPED, WHATEVER*/
      $data = array(
         'comment_post_ID' => $post["ID"],
         {RESTOF_NEEDED_COMMENT_DATA}
      );
      $cmid = wp_insert_comment($data);
      return new WP_Error( 'json_comment_created', __('Your Comment ID ' . $cmid . 'Was Created.'), array( 'status' => 201));
     }
    }
    
    add_filter('json_pre_insert_post', 'put_a_comment_errr', 10, 4);

    Extending is probably the best way to go. Then you can set your routes to '/posts/(?P<id>\d+)/comment' => array(array( array( $this, 'get_comments' ), WP_JSON_Server::EDITABLE | WP_JSON_Server::ACCEPT_JSON),),

    Either way you do it, you have to make sure you send the json data. Something like “comment_author”:”blahblah”,”comment_body”:”blahblahblah” etc… then those params will be available in your data variable.

    wp-json/posts/?type=page&filter[p]={THE_ID_OF_PAGE}

    Ok, so in order to attach a featured image to a new post, you should first create the media attachment. You do that by either sending your post data to /media (I’m using upload from data, you can also send upload from file data – probably url with an @ at the beginning of the param -). If you are posting raw data, you have to allow unfiltered uploads capabilities in your wp_config file like so:

    define( 'ALLOW_UNFILTERED_UPLOADS', true );

    Then you have to collect the file data:

    $filename = $_FILES['uploadedfile']['tmp_name'];
    $finfo = new finfo(FILEINFO_MIME_TYPE);
    $fmime = $finfo->file($filename);
    $handle = fopen($filename, "r");
    $fdata = fread($handle, filesize($filename))

    ;

    Then pass the data via curl (if you’re using curl):

    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type:".$fmime, 'Content-Disposition: attachment; filename="' .$_FILES['uploadedfile']['name'] . '"', "Accept:application/json"...

    and post that data:

    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fdata);

    If all is well, you should get a 201 created response status.

    The returned data will include the new media attachment id:

    $attachnfo = json_decode($result);
    echo $attachnfo->ID;

    Check for that status and if returned, go about creating a new post. To make sure the new post has the featured image set, make sure your params include a post_meta array with the meta key _thumbnail_id set to the returned ID of the successful attachment.

Viewing 15 replies - 76 through 90 (of 213 total)