Skip to:
Content
Pages
Categories
Search
Top
Bottom

Testing user privileges

  • @ajtruckle

    Participant

    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

    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 ;

    @ajtruckle

    Participant

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

    Thanks alot.

    @robin-w

    Moderator

    🙂

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