Support » Plugins » Hacks » Make posts sticky based on user role

  • I would like to disable manual sticky functionality and just have it so certain roles, e.g. editor, publish posts that are sticky by default, and other roles, e.g. contributor, just have normal, non-sticky posts. Is this possible? Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    While it’s easy to do something by capability, doing something by role is not. You’ll need your own function to query the usermeta table to get the current user’s role.

    Since showing stickies is normal, you need an exception to handle those that are not shown stickies. Something like this before the loop:

    if ( 'Editor' != your_get_current_role() )
        query_posts( array( 'post__not_in' => get_option( 'sticky_posts' ) ) );

    Code not verified, it’s just to illustrate a direction to take.

    Actually, I just created new capabilities with the name of the role.

    Then I used current_user_can(‘Premium Employer’)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Make posts sticky based on user role’ is closed to new replies.