Skip to:
Content
Pages
Categories
Search
Top
Bottom

Testing user privileges


  • Chuckie
    Participant

    @ajtruckle

    I have this code:

    // check frontend user privileges
    $canEdit = is_user_logged_in() && (current_user_can('edit_posts') || current_user_can('edit_pages'));

    But I am not sure it is right. Front end users who are logged in can’t create or edit posts on my site but they can create an edit forum topics and replies.

    What is the correct syntax?

Viewing 3 replies - 1 through 3 (of 3 total)

  • Robin W
    Moderator

    @robin-w

    bbpress uses

    edit_topics and edit_replies so doesn’t use the capabilities above

    but suspect your code needs an if statement, so I’d do

    // check frontend user privileges
    if ( is_user_logged_in() && ( (current_user_can('edit_posts') || current_user_can('edit_pages') ) ) $canEdit = true ;

    Chuckie
    Participant

    @ajtruckle

    Thanks. Only mistake there is that you forgot to insert your corrected edit terms into the if statement. 🙂

    Thanks alot.


    Robin W
    Moderator

    @robin-w

    🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar