• Resolved Jonas Lundman

    (@jonas-lundman)


    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 SharePress

    The 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.

    http://wordpress.org/extend/plugins/sharepress/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Aaron Collegeman

    (@aaroncollegeman)

    Hey Jonas! Thanks for working so hard on this. We’re going to see if we can support Postie officially. If it works out, it will be in version 2.2.14.

    Thread Starter Jonas Lundman

    (@jonas-lundman)

    The Postie has been updated a lot during this summer and I don know if the routines are the same anymore. I cant test it until I go live with a new project, couse SharePress cant run from Localhost (because FB wouldnt connect ya -in my server configs anyway)

    A new test with theese two very useful setups, will be about one week. Im gonna try remeber reporting here…

    I get the following error back in an email response

    SharePress Error: No publishing Targets selected.; while sending “” to Facebook for post 844

    To retry, simply edit your post and save it again:
    http://hbg-kbh.dk/wp-admin/post.php?action=edit&post=844

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘SharePress and Postie (post by mail) hack and fix’ is closed to new replies.