Skip to:
Content
Pages
Categories
Search
Top
Bottom

PHP if… else Help Required


  • traceyshaw
    Member

    @traceyshaw

    Hi,

    In my template I want to specify that one of my forums can be posted to by admins only, and other users can only reply.

    I figured the best way (and I know it’s not foolproof, but at least I can make it more difficult for people to do!) would be to use an if… else statement, but I’m not sure how to correctly write it.

    In non-PHP structure: “if the forum ID is 2 and the user is an admin, show the ‘add topic’ link; and if the forum is not equal to 2 then show the link to all registered members (in other words, let them see the ‘add topic’ link in every other forum except 2) “.

    If you could please assist a php-noob by showing me the correct structure for this statement, it’d be much appreciated.

    Also, if you know of a better way to make one forum admin-post only and member-reply only (while the others forums remain as they are now), I’m all ears! Well, all eyes since I’ll be reading rather than listening.

    Thank you so much in advance!

Viewing 1 replies (of 1 total)

  • _ck_
    Participant

    @_ck_

    bbPress has a function to check for administrators.

    if (!in_array(intval($GLOBALS['forum']->forum_id), array(2,5,9)) || bb_current_user_can('administrate')) { do something here }

    where 2,5,9 is the list of forum numbers you want to restrict

    what you are trying to do is possible but very tricky

    For example the “add new” on the front page offers all the forums for posting and you’d have to write a replacement for the list (bb_new_topic_forum_dropdown)

    All the “magic” happens in post-form.php, so you could take that if statement above and wrap the entire template with that (in theory).

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.