The Postie Shortcodes AddOn allows you to create your own shortcodes that Postie will use when turning your email into a post.
Not a programmer? I do custom development and can help you. Contact me
Step one is to register an action hook named “postie_register_shortcode” – something like this:
add_action('postie_register_shortcode', 'registermycustompostieshortcodes'); function registermycustompostieshortcodes(){ add_shortcode('myshortcode', 'myshortcodefn'); } function myshortcodefn() { return "shazam!"; }
You can put this code in the postiefilter.php file or your own plugin or theme. The shortcode will be evaluated after the email has been processed, but before it has been saved (during the postie_post_before filter). This is very different than normal shortcodes which are processed every time the post is displayed.
Note that you should not call add_shortcode() outside the postie_register_shortcode action otherwise Postie will not know about it and your post won’t look right.
Here is a more complex and realistic example:
add_action('postie_register_shortcode', 'registermycustompostieshortcodes2'); function registermycustompostieshortcodes2(){ add_shortcode('forceadmin', 'myforceadmin'); } function myforceadmin() { global $postie_post; $postie_post['post_author'] = 0; //admin user return ''; }
Note the global $postie_post declaration. This global variable gives you access to all the fields about to be used to save the post. Of note is the fact that the post does already have a post id assigned in case you need to take some action that requires a post id. You can access the post id like so: $postie_post[‘ID’]. See this page of a list of possible array values.