• Resolved strategeek

    (@strategeek)


    Hi Robin.

    I have another question, maybe you can give me a clue. Playing with front end user creation and auto subsribtion to forums. It works fine, I just need to get a list of forum IDs that are assigned to a private group.

    Was going through the souce code of bbp private groups, but could not find it.

    I can get a a private group assigned to the role.
    I can get it either as group1 or as real group name.

    echo ($rpg_roles[$user_role]);
    $name2= $rpg_roles[$user_role];
    echo ($rpg_groups[$name2]);

    But how to get forum IDs (array) that belong to the specific private group. I have no clue. Any ideas?

    https://www.ads-software.com/plugins/bbp-private-groups/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Robin W

    (@robin-w)

    if you go to

    wp-content/plugins/bbp-private-groups/includes/settings.php

    lines 289 – 365 have the management information in.

    So if you change line 342 to

    echo '<li>'.$forum.' '.$ftitle.'</li>' ;

    and then look at

    dashboard>settings>bbp private groups>management information

    you will see each group listed together with the forums and ID’s in that group.

    So you should then be able to extract the code you need.

    In essence wp_options ‘rpg_groups’ holds the group names and lines 322 to 344 loop round the forums to see which belong to each name in turn by looking in post meta for that forum under ‘_private_group’

    Hoper that all helps, but do come back if you need more help.

    Thread Starter strategeek

    (@strategeek)

    Hi Robin. Thank you for the clue!

    I have finally made it. Now after user creation, the new user will be automatically subscribed to the forum(s) that belong to the private group which is assigned to the user role.

    $name2= $rpg_roles[$user_role];
    	$forums=$wpdb->get_col("select ID from $wpdb->posts where post_type='forum'") ;
    	foreach ($forums as $forum) {
    		$meta = (array)get_post_meta( $forum, '_private_group', false );
    		foreach ($meta as $meta2) {
    			if ($meta2==$name2) {
    			if ( !function_exists( 'bbp_add_user_forum_subscription' ) ) {
    			require_once ABSPATH . PLUGINDIR . '/bbpress/includes/users/functions.php';
    			}
    			$forum_id = $forum;
    			bbp_add_user_subscription($user_id, $forum_id);
    			}
    		}
    	}
    Plugin Author Robin W

    (@robin-w)

    Hey great – glad I was of help

    I’ll mark this topic as resolved, but do come back if I can help further

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to get forum IDs that are assigned to a private group?’ is closed to new replies.