WordPress.org

Ready to get started?Download WordPress

Forums

Make posts sticky based on user role (3 posts)

  1. publicradio
    Member
    Posted 2 years ago #

    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.

  2. bcworkz
    Member
    Posted 2 years ago #

    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.

  3. publicradio
    Member
    Posted 2 years ago #

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

    Then I used current_user_can('Premium Employer')

Topic Closed

This topic has been closed to new replies.

About this Topic