WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Post by mail - linking multiple emails to specific categories (2 posts)

  1. JonasNielsen
    Member
    Posted 4 years ago #

    Hi all,

    I'm getting started with WordPress 3, and I really enjoy it.

    I'm stuck with this problem:
    The post by mail really looks useful. Because I have different user groups on my site managing different categories, I would really like to have the option to monitor different email addresses.
    So for instance
    Managers can email managerpost@mysite.com and post to managers category
    assistants can email assistantpost@mysite.com and post to assistants category
    (etc.)

    Is that somehow possible? Is there perhaps an existing plugin that supports this?

    If not, would you consider it impossible to implement? If I'm not able to code it myself I would presumably be willing to pay for it.

  2. JonasNielsen
    Member
    Posted 4 years ago #

    Ok, I actually managed to solve this problem with a kinda hack.

    Googling some more, I discovered the Postie plugin

    This plugin lets you customize the post by mail a lot, but what I found really interesting, was that it also comes with a Postie Filter plugin. Basically, this is just a file that lets you program custom filters that is applied to incoming mails.

    By using this approach, I was able to program a very short script, that alters the author id and category id of the post, according to the author of the email.

    If the email author is not recognized as one of the manually programmed emails, the post will be moved to the trash folder.

    Following is an example of the content inside filterPostie.php

    function filter_category($post){
    	$VICEVAERT_EMAIL = 'lahmadance@gmail.com';
    	$VICEVAERT_CATEGORY_ID = 4;
    	$VICEVAERT_USER_ID = 3;
    
    	$BESTYRELSEN_EMAIL = 'bestyrelsen@ikkeendnu.com';
    	$BESTYRELSEN_CATEGORY_ID = 3;
    	$BESTYRELSEN_USER_ID = 4;
    
    	$AKTIVITETSUDVALGET_EMAIL = 'bestyrelsen@ikkeendnu.com';
    	$AKTIVITETSUDVALGET_CATEGORY_ID = 5;
    	$AKTIVITETSUDVALGET_USER_ID = 5;
    
    	if($post['email_author'] == $VICEVAERT_EMAIL){
    		$post['post_category'][0] = $VICEVAERT_CATEGORY_ID;
    		$post['post_author'] = $VICEVAERT_USER_ID;
    	}
    	else if($post['email_author'] == $BESTYRELSEN_EMAIL){
    		$post['post_category'][0] = $BESTYRELSEN_CATEGORY_ID;
    		$post['post_author'] = $BESTYRELSEN_USER_ID;
    	}
    	else if($post['email_author'] == $AKTIVITETSUDVALGET_EMAIL){
    		$post['post_category'][0] = $AKTIVITETSUDVALGET_CATEGORY_ID;
    		$post['post_author'] = $AKTIVITETSUDVALGET_USER_ID;
    	}
    	else {
    		$post['post_status'] = 'trash';
    	}
      	return ($post);
    }
    add_filter('postie_post', 'filter_category');

Topic Closed

This topic has been closed to new replies.

About this Topic