Community forum only for site admins and users

Hi,

I want to create
domain.com/community/ as a subsite hosting the forums for the whole multisite so the forum would be at
domain.com/community/forum/
But I want the forums ONLY to be accessible/editable for already-registered site admins, registered elsewhere on the site eg site owners of
domain.com/site1
domain.com/site2
and for site users of those sites.

ie the forum is not accessible by normal registration at
domain.com/community/forum
Instead they must already be registered as a site admin or site user elsewhere on the domain.com

What is the best way to enable this?

Thanks

  • Jack Kitterhing
    • Code Norris

    Hi there Duncan,

    Hope you're well today and thanks for your question.

    The best here would be to use a Membership plugin like ours or similar, where you can protect certain URL's.

    This means that you can then assign the members a Membership level to access the forums, if that makes sense?

    Thanks!

    Kind Regards
    Jack.

  • Duncan
    • Site Builder, Child of Zeus

    I was thinking more along the lines of how this forum is set up here - I believe it is a separate WP install in your /forums/ folder - yet I never registered at /forums/ - I purchased elsewhere on the site.

    How might I enable a similar feature?

  • Duncan
    • Site Builder, Child of Zeus

    Also, I dont want to block the search engine bots from the threads of the forum, so I dont want to protect and hide the forum thread - only that the forums can only be added to by the existing site admins and their users

  • Duncan
    • Site Builder, Child of Zeus

    So according to the "Forum Roles" section on that page, under #9 - "Participant"
    "This is a WordPress Multisite role only. This allows the user on one site of a network to participate in a forum on another site on your network without having to register on the other site. Participants can publish and edit their own topics and replies"

    So we need to assign each site admin as having forum role "Participant" in this ddpress site-wide forum.

    ANy pointers on tat more specifically please? Is there an option anywhere in settings? Or is this somethign that would need to be programmed in? Which database table etc should this go into? Are there specific instrucitons on how to do this part?

    Thanks

  • DavidM
    • DEV MAN’s Mascot

    Hi @Duncan,

    Thanks for your patience with this. Just wondering though, Jack originally mentioned our Membership plugin:
    https://premium.wpmudev.org/project/membership/

    Rather than needing to code something, would that work for you?

    It's not the specific means used here on this site, but it's very effective as Membership has full user role integration. You can specify a user role per each Access Level in Membership.

    Off the top of my head, I recall bbPress using roles for features as well, so that'd work great alongside Membership too.

    Plus, Membership has URL Groups features which let you restrict access on a url basis. That could be used in Multisite as well.

    Does that sound viable to you?

    Cheers,
    David

  • Duncan
    • Site Builder, Child of Zeus

    HI David, as I said earlier
    Also, I dont want to block the search engine bots from the threads of the forum, so I dont want to protect and hide the forum thread - only that the forums can only be added to by the existing site admins and their users .

    My understanding is that Membership would make invisible to the search engines forums that are protected. This is not what I want. I want that only existing site admins can participate int he forums, but that anyone can view them

  • Hoang Ngo
    • Code Slayer

    Hi there @Duncan,

    I hope you are well today.

    My understanding is that Membership would make invisible to the search engines forums that are protected. This is not what I want. I want that only existing site admins can participate int he forums, but that anyone can view them

    Yes, because google cached the pages, so If we don't hide it from google, it will be a security hole for the membership plugin.

    If you rule is fixed at only site admin can participate, the rest only read, so we can archive this feature by below code:

    add_action( 'init', 'check_rule_to_participate_forum' );
    function check_rule_to_participate_forum() {
    	if ( is_user_logged_in() && ! current_user_can( 'manage_options' ) && isset( $_GET['action'] ) ) {
    		if ( $_GET['action'] == 'new_topic' ) {
    			echo 'Sorry, you can only view';
    			exit;
    		} elseif ( $_GET['action'] == 'new_post_process' ) {
    			echo 'Sorry, you can only view';
    			exit;
    		}
    	}
    }
    
    add_action( 'wp_footer', 'hide_participate_forum_action' );
    function hide_participate_forum_action() {
    	if ( is_user_logged_in() && ! current_user_can( 'manage_options' ) ) {
    		?>
    		<script type="text/javascript">
    			jQuery(document).ready(function ($) {
    				//find all the a tag
    				$('a').each(function () {
    					if ($(this).text() == '<?php  _e( 'Click here to create a new topic.', 'wpmudev_forums' ) ?>') {
    						$(this).attr({
    							'href'    : '#',
    							'disabled': 'disabled'
    						}).text('Sorry, you can not create new topic');
    					}
    				});
    				$('form[name="new_topic"]').prev('h3').remove();
    				$('form[name="new_topic"]').remove();
    			})
    		</script>
    	<?php
    	}
    }

    This will firstly block the request if user role is not admin. And it will remove/changes the link/form to normal user. They can not participate the forum anymore.

    Best Regards,
    Hoang

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.