[resolved] Filtering post via email (3 posts)

  1. Neil
    Posted 2 years ago #


    I am trying to filter posts made via email. If the email post contains a name, it will go to pending status. On wp-mail.php, after the following line:

    $post_content = apply_filters('phone_content', $content);

    I added this:

    if (preg_match("/Name Here/i", $post_content)) {
    	$post_status = 'pending';

    It seems not to work. Any ideas on how to add that filter?

  2. bcworkz
    Posted 2 years ago #

    No idea why that doesn't work. In any case, it's very poor practice to edit core WP files. The next update will overwrite your edits. Some people are reluctant to update because of this, leaving them open to newly found security exploits.

    Doing things properly can be more convoluted unfortunately. In your case, you probably should let the post be published normally. You can hook the 'publish_phone' action (why phone? don't know, that's the right one though) and get the post info from the ID you're passed. If you find the name in the content, then change the status and update the post.

    Your hook code can be placed in your own plugin, theme, or child theme.

  3. Neil
    Posted 2 years ago #

    Sorry, I tried to update the question but there was an error. Anyway, the way I have it, it worked. Just took a little longer for the post sent via email to show up on the dashboard. I will keep in mind your suggestion about not editing core files. Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic