• I’m using Adrien de Bosset’s “Force User to specific Category” function inside my functions.php file. Since I receive posts via email from multiple collegiate organizations, and tie them into the specific school they represent, I’m forcing each person’s posts to automatically go into the category for the school they represent.

    When I do a manual test post under their name (via WP Admin), the behavior operates as expected.

    When the post comes in via Postie, it’s being assigned to a standard “default” category. What I need to do is to not have Postie default to that category, but to default to the category associated with that individual poster.

    For example, in Postie, the default category is “Athletics News”.
    John Doe works with Georgia State Panthers… so his default category is gsu-panthers-news (GSU Panthers News). Postie binds the category of his post to “Athletics News”, instead of “GSU Panthers News”.

    Jane Merriweather works for Coastal Carolina Chanticleers. I’ve assigned her default category to be “CCU Chants News”. When Postie processes it, it assigns her posts to “Athletics News” and not “CCU Chants News”.

    How can I get Postie to respect the WordPress default behavior I have assigned in my functions.php file?

    Thanks!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Wayne Allen

    (@wayneallen-1)

    Unfortunately you didn’t provide enough information. What hook are you using to change the category? You might want to use the Postie hooks. See http://postieplugin.com/extending/

    Wayne, did you look at the link I provided to Adrien’s issue? That summarizes what the issue is.

    I’m not sure how to explain it any clearer than what I did above, though.

    “postie_category_default” forces EVERYONE to use whatever the WordPress default is (in my case, “uncategorized”).

    But if you look at the examples above, you’ll see that each specific user, via their profile page, is “locked” into a specific category.

    On my site:
    * John Doe is “locked” into being able to only post into the “GSU Panthers News” category. Whether he remembers to check that category or not, his posts will ALWAYS be put into the “GSU Panthers News” category.

    * Jane Merriweather is “locked” into being able to only post into the “CCU Chants News” category. Whether she remembers to check that category or not, her posts will ALWAYS be put into the “CCU Chants News” category.

    When I import the mails from John Doe and Jane Merriweather, their posts are being locked into the “Athletics News” category. Which means I then have to log in and edit each and every post to change the categories to the appropriate ones.

    As someone in sports media, doing photography (an average of 300 pics per game), if I have to also go in and modify each post (can be anywhere from 3 to 100, per day), that takes time away from me being able to do photography.

    I’m trying to work smarter, not harder. ::chuckles::

    Plugin Author Wayne Allen

    (@wayneallen-1)

    I did look at the link and asked how you are doing it as I suspect it isn’t a direct copy/paste.

    The Postie category is assigned before the post is published. So you need to use a hook that happens at the correct point. For example {status}_{post_type}

    See https://codex.ww.wp.xz.cn/Post_Status_Transitions

    I apologize… and as much as I love tinkering around with code, it is, indeed, a direct copy and paste. 🙂

    What I’m trying to ascertain is where, exactly, do I modify the postie functions file (I know it needs to go into the main wp-content folder), to have Postie use the default categories (as the original unedited script is used) each person is assigned to.

    I’m sorry for being so dense with all of this, haha! I love the Postie script, and if we can get it working, I’ll even start recommending it to some of the customers for the company I work for… and may go beyond just recommendations.

    Plugin Author Wayne Allen

    (@wayneallen-1)

    You don’t need to modify Postie at all. There are plenty of hooks to use. Look at http://postieplugin.com/postie_post_before/

    I was referring to modifying filterPostie.php, not Postie itself.

    What I’m not clear on is how to force Postie to use the assigned category, as outlined in the first link I posted, at the top.

    Plugin Author Wayne Allen

    (@wayneallen-1)

    Use the hook I specified. There is sample code in the link I sent you.

    Told you I like fiddling around with code. Did some troubleshooting, and testing, but here’s the exact code for what we need:

    <?php 
    function my_postie_post_function($post) {
            $dlhCategory = get_user_meta($post['post_author'], '_access', true);
            $post['post_category'] = $dlhCategory;
            return $post;
    }
    
    add_filter('postie_post_before', 'my_postie_post_function');
    ?>
    Plugin Author Wayne Allen

    (@wayneallen-1)

    Looks like you have it sorted.

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

The topic ‘Postie category selection’ is closed to new replies.