Support » Plugins » Hacks » Adding a custom field from content_save_pre filter through XMLRPC

  • Resolved yjsoon

    (@yjsoon)


    Is it possible to add a custom field from a content_save_pre filter? I’m trying to detect some fields being typed in the post content, e.g. [something]Thing[/something], and then set a custom field to “Thing”.

    The following code works fine when posting through the web interface, but fails on the clients I’ve tried (MarsEdit and WordPress iOS) — the [] tags get removed, but the custom field doesn’t get set.

    function dfll_get_link($post_content) {
      $dflink = dfll_find_link($post_content);
      if ($dflink) {
        global $post;
        $post_id = $post->ID;
        update_post_meta($post_id, 'linked_list_url', $dflink);
      }
      $temp = '/(' . dfll_regesc('[ll]') . '(.*?)' . dfll_regesc('[/ll]') . ')/i';
      $post_content = (preg_replace($temp, '', $post_content));
      return $post_content;
    }
    
    add_filter('content_save_pre', 'dfll_get_link');

    (Assume the other functions are defined.)

    This is for my Daring Fireball-style Linked List plugin. Code above adapted from Justin Blanton’s Slugger+ plugin.

Viewing 2 replies - 1 through 2 (of 2 total)
  • yjsoon

    (@yjsoon)

    I’ve done a bit more testing, and it seems that the post ID isn’t being generated when using external clients (or even with the Press This bookmarklet). I’d appreciate any advice at all in getting the post ID somehow. Thanks!

    yjsoon

    (@yjsoon)

    Problem solved. See how Justin Blanton does it in this plugin.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding a custom field from content_save_pre filter through XMLRPC’ is closed to new replies.