WordPress.org

Forums

Jetpack by WordPress.com
Publicize for Admin and Editor only (27 posts)

  1. pinkdreambox
    Member
    Posted 1 year ago #

    When we activated Jetpack's Publicize and connected to Facebook, we chose to use the connection for all users. But what we want is for Admins and Editors, not Author.

    From Publicize's info page on http://jetpack.me/support/publicize/, it states all users from Admin, Editor to Author's post will be publicized if we choose to "share".

    Is there anyway to limit to Admin and Editor only?

    Thanks,

    http://wordpress.org/plugins/jetpack/

  2. Richard Archambault
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    What are you trying to do exactly? Are you trying to remove the Publicize options box and still have the Author's posts be Publicized, or do you not want the Author's posts to be Publicized at all?

  3. pinkdreambox
    Member
    Posted 1 year ago #

    Hi Richard,

    Thanks for the reply.

    Like you said, we do not want the posts of users with the Author-role to be Publicized.

    Only Admin and Editor's posts will be publicized.

    Best regards,

  4. Richard Archambault
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    Hi there,

    Try this code in your theme's functions.php or in a custom plugin for your site:

    add_filter( 'wpas_submit_post?', 'publicize_only_editor_and_admin_filter', 10, 4);
     
    function publicize_only_editor_and_admin_filter( $submit_post, $post_id, $service_name, $connection_data ) {
      if ( current_user_can ('moderate_comments') ) {
        return true;
      }
      return false
    }

    This code is untested, but should work. Try that and let me know if it works for you!

  5. pinkdreambox
    Member
    Posted 1 year ago #

    Hi Richard,

    Thanks for the code and reply.

    We will start testing today!

  6. pinkdreambox
    Member
    Posted 1 year ago #

    Hi Richard,

    We tried on the site and added the code in a custom plugin.

    When under Author's New Post Screen, author cannot select which Publicize channel (as it is not displayed) So we thought it worked. After we hit publish the post to post a test article.

    It was publicized to all the Publicized connections we set up in while in Admin role.

    So seems like the code above is not preventing Author's post from being Publicized.

    Like you said it is untested. Hope you would be able to try it out and see if the same result occurs on your test.

    Thanks

  7. Richard Archambault
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    Can you try changing "moderate_comments" to "publish_pages" ?

  8. pinkdreambox
    Member
    Posted 1 year ago #

    Will try the new rule today. Thanks.

  9. pinkdreambox
    Member
    Posted 1 year ago #

    Tried a few times, the posts by Author are still being push to Facebook. Really hope we can limit Publicize to work for Admin and Editor's posts only.

  10. Richard Archambault
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    Hi!

    Can you let me know what you've tried? Have you modified the code at all?

  11. pinkdreambox
    Member
    Posted 1 year ago #

    Hi Richard,

    Sorry for the late reply.

    We have added the modified code you mentioned above from "moderate_comments" to "publish_pages".

    Here is the code

    // Jetpack Publicize for Admin & Editors only 
    
    add_filter( 'wpas_submit_post?', 'publicize_only_editor_and_admin_filter', 10, 4);
    
    function publicize_only_editor_and_admin_filter( $submit_post, $post_id, $service_name, $connection_data ) {
      if ( current_user_can ('publish_pages') ) {
        return true;
      }
      return false;
    }

    The result is that, user role Author's post will still be Publicized.

    Did you have the same test result?

  12. pinkdreambox
    Member
    Posted 1 year ago #

    Hope there will be a place for setting only Admin and Editor can use the Publicize function.

  13. bendunn135
    Member
    Posted 1 year ago #

    Hi,

    I've been fighting with the same problem. The issue doesn't seem to be what you put in the "wpas_submit_post?" function, more than whether you return False or True, it goes ahead and posts anyway.

    It's being used, as I can receive debug info through it, but True or False it still posts.

  14. bendunn135
    Member
    Posted 1 year ago #

    Even though this line of code is 100% being run, it doesn't make any difference.

    delete_post_meta( $post_id, $this->PENDING );

    Shouldn't that stop it being posted?

  15. pinkdreambox
    Member
    Posted 1 year ago #

    Any update from the development team?

    As our authors will use WordPress iOS App to publish their posts so need a way to restrict the Publicize for only Editor and Admin.

    Thanks,

  16. Richard Archambault
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    Hi all,

    I gave it another shot this afternoon but still can't get it to work aspexpected. I will tackle it with another developper tomorrow. I'll keep you posted!

  17. Richard Archambault
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    Hi!

    It turns out that we needed to apply a patch to Jetpack to make this work properly. This patch should fix it, but is not live in Jetpack at the moment. We're currently in the beta stages for Jetpack 2.9; I am not certain if this will make to the final release of 2.9 but I'll see if it can be added. Otherwise, you can modify the plugin file yourself and add those new lines to it, and then try your code again. I believe it will work with the current version of Jetpack just by modifying the file, but I had inconsistent sesults this morning while trying with my colleague; my tests failed every time (the post was publicizied), whereas his tests worked (no post was publicized). The difference is that I was running a modified file with Jetpack 2.8 whereas he was running the the Master branch from github (which includes other changes, none of which should affect this as far as I am aware but I may be mistaken).

    In any case, I will see to it that this be included in the 2.9 release, and the code to prevent authors from Publicizing should work then. We'll keep in touch to see this resolved once and for all! :)

  18. pinkdreambox
    Member
    Posted 1 year ago #

    Thanks for the update.

    It will be great to have this work!

  19. Bill Huber
    Member
    Posted 1 year ago #

    Sorry to jump in here but I am guessing by trying to fix the problem with "Publicize for Admin and Editor only" you created a new problem with publicizing posts created using Live Writer and maybe other methods. I went back to the 2.8 version of publicize and it works for me. I will do more testing today on another blog I have to confirm that 2.8 still works. Here is the code I am talking about.

    304,308d303
    < 				if ( false == apply_filters( 'wpas_submit_post?', $submit_post, $post_id, $service_name, $connection_data ) ) {
    < 					delete_post_meta( $post_id, $this->PENDING );
    < 					continue;
    < 				}
    <
    312a308,312
    >
    > 				if ( false == apply_filters( 'wpas_submit_post?', $submit_post, $post_id, $service_name, $connection_data ) ) {
    > 					update_post_meta( $post_id, $this->POST_SKIP . $unique_id, 1 );
    > 					continue;
    > 				}
  20. Richard Archambault
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    @Bill: I'm not certain that the change you mention is the source of the problem, but we're looking into it, and are aware of the issue:

    https://github.com/Automattic/jetpack/issues/314

    @pinkdreambox, @bendunn135: Were you able to limit Publicize to admins and edtiors only, with the 2.9 release?

  21. Bill Huber
    Member
    Posted 1 year ago #

    Sorry, I did not get back to you earlier. I have been a little busy with my day job. I was curious about what were the developers trying to fix since the code change seems unrelated to Live Writer and fixing the problems with Admin/Editor Only. I just know that the old code works and the new code does not work. Here are two blogs I am using the 2.8 version of publicize.php on successfully. Everything else in Jetpack is 2.9.

    http://alazycowboy.com/

    http://wehuberconsultingllc.com/wordpress/.

  22. Richard Archambault
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    Thanks, Bill. I'll update here when we have news.

  23. George Stephanis
    Automattic Lead Code Monkey
    Plugin Author

    Posted 1 year ago #

    Just to clarify, the changeset that Bill is detailing is:

    https://github.com/Automattic/jetpack/commit/2beb14cce962d53a05df0f655f5db47d5fdbaad3

  24. pinkdreambox
    Member
    Posted 1 year ago #

    Will do the testing again with JetPack 2.9

  25. Richard Archambault
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    pinkdreambox, can you try with 2.9.2, and let me know if it worked for you this time?

  26. pinkdreambox
    Member
    Posted 1 year ago #

    Sorry for the late reply. Will do the 2.9.2 test.

  27. pinkdreambox
    Member
    Posted 1 year ago #

    Thank you Richard @richardmtl for seeking way to solve this.

    Sorry for the late reply. After updated to WordPress 3.8, half of our sites' themes got some conflicts and caused some errors. So need to fix those live sites before further tests.

    And finally got the chance to test out Jetpack 2.9.3 with WordPress 3.8.3 and with the code below to try and limit the Publicize function to Admin and Editors only.

    But when the Author on the site publish the post, it still got Publicized.

    Are we using the right code (the one below) or we should be using different configuration to work with new Jetpack 2.9.3.

    // Jetpack Publicize for Admin & Editors only 
    
    add_filter( 'wpas_submit_post?', 'publicize_only_editor_and_admin_filter', 10, 4);
    
    function publicize_only_editor_and_admin_filter( $submit_post, $post_id, $service_name, $connection_data ) {
      if ( current_user_can ('publish_pages') ) {
        return true;
      }
      return false;
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Jetpack by WordPress.com
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic