SharePress and Postie (post by mail) hack and fix
-
The Postie plugin and SharePress seems for me to have this problem:
– The User role cant be found and SharePress return a not allowed log
– The Post is already published by Postie, and treated so by SharePressThe latter need the post by Postie to be enabled for sharing, since the post is not submitted by the Publish now button in the edit page.
I tried to find a solution with this issue but could not. So I presenting my hack that works for now, to see if anyone can make a better hook for a clean soultion.
The cleaner part: Add this in your functions.php
function postie_post_sharepress($post) { add_filter('sharepress_user_can_edit_post', 'ua_sharepress_user_can_edit_post', 99, 2); add_filter('sharepress_ignore_save_nonce', 'ua_sharepress_ignore_save_nonce', 99, 1); return $post; } add_filter('postie_post', 'postie_post_sharepress'); function ua_sharepress_user_can_edit_post($status, $post) { //$title = is_object($post) ? $post->post_title : $post; //if($title == 'tmptitle') return false; $GLOBALS['sharepress_enable_is_on'] = 1; return true; // REMARK TRUE // This is just test notes, func already returned // The purpose is to change the value: $_POST[self::META]['enabled'] = 'on'; IN sharepress.php, // but I don now how to access and store it here // Maybe Something like, but I don dear to test it, Im on live site... $id = $post->ID; $meta = get_post_meta($id, 'sharepress_meta', false); if($meta && $meta['enabled'] != 'on'){ $meta['enabled'] = 'on'; update_post_meta($id, 'sharepress_meta', $meta); } return true; } function ua_sharepress_ignore_save_nonce($status) { if(isset($GLOBALS['sharepress_enable_is_on'])) unset($GLOBALS['sharepress_enable_is_on']); return true; // REMARK TRUE }
The
unset($GLOBALS['sharepress_enable_is_on'])
may not be needed.The HACK: around Line 971 in sharepress.php, plugin root folder you will find a comment verify permissions
// verify permissions if (!$is_cron && !apply_filters('sharepress_user_can_edit_post', false, $post) && !current_user_can('edit_post', $post->ID)) { self::log("Current user is not allowed to edit posts; ignoring save_post($post_id)"); return false; }
Direct after this, add this LINE:
if(isset($GLOBALS['sharepress_enable_is_on'])) $_POST[self::META]['enabled'] = 'on'; // QQ - marker to find hack in core files by search in files
The complete part shoul look like this:
// verify permissions if (!$is_cron && !apply_filters('sharepress_user_can_edit_post', false, $post) && !current_user_can('edit_post', $post->ID)) { self::log("Current user is not allowed to edit posts; ignoring save_post($post_id)"); return false; } if(isset($GLOBALS['sharepress_enable_is_on'])) $_POST[self::META]['enabled'] = 'on'; // QQ - marker to find hack in core files by search in files
The
$_POST[self::META]['enabled'] = 'on'
should be accessible and fixed in the filters earlier somhow, bu I don know hot to access this class from outside.Please contribute to a cleaner fix all the way.
- The topic ‘SharePress and Postie (post by mail) hack and fix’ is closed to new replies.