Forum Replies Created
-
Sorry, I think I misunderstood your question from the beginning. You’re not trying to display topics on the front page of a group. You’re trying to show topics on the site’s front page? If so, what I’ve talked about won’t help at all. 🙁
In looking into bbPress, I can’t really see how a particular forum is associated with a group. So I’m afraid I’m not going to be much help. Maybe someone else knows more about bbPress’s group forum integration?
That’s too bad. A couple of questions I should have asked at the beginning:
- What theme are you using?
- If you remove the conditional we added, does bbPress return topics for the correct group?
Put this before the code we’ve been talking about, and see what it displays on the page:
$test_id = bp_get_current_group_id(); echo 'The current group ID is:' . $test_id;If it returns a number besides zero (zero means that it can’t figure out which group is the current group, a non-zero number is the current group ID), then you could probably adjust the conditional code:
if ( bp_group_is_visible( bp_get_current_group_id() ) ) { //do the topics loop here }Fingers crossed.
When you say it didn’t work, do you mean that people who should see the topics couldn’t, or that no one could see the topics, or that everyone could see the topics? Was it too generous in letting people through or did it keep everyone out? 😉
Also, could it be that this is this being used in a sidebar? I’m wondering if the placement on the page means that the group context is not certain, so you’d need to pass the group_id into
bp_group_is_visible. Although I’d expect thebbp_topicsto need to access the group_id as well.You should be able to wrap your bbp_has_topics output in a conditional like:
if ( bp_group_is_visible() ) { //do the topics loop here }bp_group_is_visiblechecks to see if the group is public or private, and if it’s public, returns true. If not public, then it checks to see if the user is a member of the current group; if yes, it returns true. It’s located at /bp-groups/bp-groups-template.php -> line 377.function bp_group_is_visible( $group = false ) { 378 global $groups_template; 379 380 if ( bp_current_user_can( 'bp_moderate' ) ) 381 return true; 382 383 if ( empty( $group ) ) 384 $group =& $groups_template->group; 385 386 if ( 'public' == $group->status ) { 387 return true; 388 } else { 389 if ( groups_is_user_member( bp_loggedin_user_id(), $group->id ) ) { 390 return true; 391 } 392 } 393 394 return false; 395 }I’m assuming you’re talking about navigation items. You can add some conditionals around individual items to only show them only if the user is logged in. Use this WP function: https://codex.wordpress.org/Function_Reference/is_user_logged_in
That’s not as easily done if the item is in a WP-created navigation menu. This plugin looks promising: https://wordpress.org/plugins/menu-items-visibility-control/
-David
Shuklaamar- Be aware that if you edit core files as that web page suggests, you’ll have to make that same edit every time you update WordPress.
Honestly, my experience with WordPress on IIS hasn’t been that great. The rewrite/redirects are one thing, but the FastCGI implementation is not very robust, which can cause grief.
Polly- Your problem doesn’t appear to be related to the original question. I think you’re right that the problem is the theme, so contacting the theme author would be a good start.
-David
I did solve this by moving the logic that enables the action into the screen function, instead of attaching a separate function to bp-actions.
So the screen function first looks to see if that action is requested. If so, it does it, then redirects. Otherwise it isn’t enabled and the template kicks in.
This is the approach taken in the BP-Skeleton-Component accept/reject terms example.
I’ve altered this slightly to make it more like the BP-Skeleton-Component’s example (adding the screen name to the uri) and my action is still not catching the URI:
My button’s link looks like:
http://site.local/members/username/library/maps/delete-map/57/2/value?_wpnonce=12345678My action’s filter:
if ( bp_is_current_component( 'library' ) && bp_is_current_action( 'maps' ) && bp_is_action_variable( 'delete-map', 0 ) )Part of the $bp global:
Array ( [component] => library [action] => maps [action_variables] => Array ( [0] => delete-map [1] => 57 [2] => 2 [3] => value ) )I’m no longer getting a 404. Now the URI lands on the “maps” screen, which is the default screen of the component, but keeps the long URI intact. I can verify that my component/action/variable filter works by adding the code to the screen:
if ( bp_is_current_component( 'library' ) && bp_is_current_action( 'maps' ) && bp_is_action_variable( 'delete-map', 0 ) ) { echo "The conditions are satisfied."; }I’m wondering if maybe I should just perform this action using AJAX. Any ideas? Thanks in advance for your help.
-David
That’s interesting. (I don’t see that behavior on my LAMP or IIS installations.)
Do you have the “Custom Structure” option with an empty text field? You could try http://localhost/wp-sqlsrv/%monthnum%/%postname%/ that way.
What happens to your site if you switch your permalinks to simply be http://localhost/wp-sqlsrv/%postname%/ or http://localhost/wp-sqlsrv/%month%/%postname%/?
Thanks for the response. Hooking to bp_init doesn’t fix the behavior, though.
-David
I’ve also used WP on IIS with mixed success. However, I’ve never tried to use SQL Server to host the db. Your rewrite rules look right to me. How have you set your permalink settings up within WP (from the Admin area, it’s at Settings > Permalinks)?
-David
Hi Modemlooper-
My theme is a child theme of Twenty Twelve, so my style.css declares Template: twentytwelve.
I followed your suggestion then took it a step farther and included slightly modified version of the js setup functions from the template pack in my `functions.php` file. I’ll post them here in case somebody else has the same problem I’m having:
`function bp_support_theme_setup() {
global $bp;// Load the default BuddyPress AJAX functions if it isn’t explicitly disabled or if it isn’t already included in a custom theme
if ( ! function_exists( ‘bp_dtheme_ajax_querystring’ ) )
require_once( BP_PLUGIN_DIR . ‘/bp-themes/bp-default/_inc/ajax.php’ );// Let’s tell BP that we support it!
add_theme_support( ‘buddypress’ );if ( ! is_admin() ) {
// Register buttons for the relevant component templates
// Friends button
if ( bp_is_active( ‘friends’ ) )
add_action( ‘bp_member_header_actions’, ‘bp_add_friend_button’ );// Activity button
if ( bp_is_active( ‘activity’ ) )
add_action( ‘bp_member_header_actions’, ‘bp_send_public_message_button’ );// Messages button
if ( bp_is_active( ‘messages’ ) )
add_action( ‘bp_member_header_actions’, ‘bp_send_private_message_button’ );// Group buttons
if ( bp_is_active( ‘groups’ ) ) {
add_action( ‘bp_group_header_actions’, ‘bp_group_join_button’ );
add_action( ‘bp_group_header_actions’, ‘bp_group_new_topic_button’ );
add_action( ‘bp_directory_groups_actions’, ‘bp_group_join_button’ );
}// Blog button
if ( bp_is_active( ‘blogs’ ) )
add_action( ‘bp_directory_blogs_actions’, ‘bp_blogs_visit_blog_button’ );
}
}
add_action( ‘after_setup_theme’, ‘bp_support_theme_setup’, 11 );/**
* Enqueues BuddyPress JS and related AJAX functions
*
* @since 1.2
*/
function bp_support_enqueue_scripts() {// Add words that we need to use in JS to the end of the page so they can be translated and still used.
$params = array(
‘my_favs’ => __( ‘My Favorites’, ‘buddypress’ ),
‘accepted’ => __( ‘Accepted’, ‘buddypress’ ),
‘rejected’ => __( ‘Rejected’, ‘buddypress’ ),
‘show_all_comments’ => __( ‘Show all comments for this thread’, ‘buddypress’ ),
‘show_all’ => __( ‘Show all’, ‘buddypress’ ),
‘comments’ => __( ‘comments’, ‘buddypress’ ),
‘close’ => __( ‘Close’, ‘buddypress’ )
);// BP 1.5+
if ( version_compare( BP_VERSION, ‘1.3’, ‘>’ ) ) {
// Bump this when changes are made to bust cache
$version = ‘20120412’;$params[‘view’] = __( ‘View’, ‘buddypress’ );
$params[‘mark_as_fav’] = __( ‘Favorite’, ‘buddypress’ );
$params[‘remove_fav’] = __( ‘Remove Favorite’, ‘buddypress’ );
}
// BP 1.2.x
else {
$version = ‘20110729’;if ( bp_displayed_user_id() )
$params[‘mention_explain’] = sprintf( __( “%s is a unique identifier for %s that you can type into any message on this site. %s will be sent a notification and a link to your message any time you use it.”, ‘buddypress’ ), ‘@’ . bp_get_displayed_user_username(), bp_get_user_firstname( bp_get_displayed_user_fullname() ), bp_get_user_firstname( bp_get_displayed_user_fullname() ) );
}// Enqueue the global JS – Ajax will not work without it
wp_enqueue_script( ‘dtheme-ajax-js’, BP_PLUGIN_URL . ‘/bp-themes/bp-default/_inc/global.js’, array( ‘jquery’ ), $version );// Localize the JS strings
wp_localize_script( ‘dtheme-ajax-js’, ‘BP_DTheme’, $params );
}
add_action( ‘wp_enqueue_scripts’, ‘bp_support_enqueue_scripts’ );
`Which is identical to installing the template pack only for the JS, I think. Everything’s working as expected, so I think we can consider this problem resolved. Thanks for your attention, Hugo and Modemlooper.
-David
Still didn’t work. Available here: http://pastebin.com/ZtFWhqyg
Well that code bit got mixed up, let’s try that again:
`<a href="” title=”Log out”>`
Hi Patty-
Have you tried using `home_url()` instead of `site_url()` like the example on the Codex: https://codex.wordpress.org/Function_Reference/wp_logout_url#Logout_and_Redirect_to_Homepage
I use this on my site and it redirects to the home page:
`<a href="” title=”Log out”>`-David
Hi Hugo-
You just cleared something important up for me: The new file structure is not just a restructuring of where the files are, but also within the files themselves. (And the files in /buddypress/bp-templates/bp-legacy/buddypress/ are the new style. Are these the template files that theme compat uses, too?)
Yes, I built this theme the old way, where you create a child theme of whatever (I used Twenty Twelve), then copied the templates and css over from bp-default into the child theme, then went to work. It’s not a child theme of bp-default (precisely, but more or less). The BP Template Pack took care of the JS with BP1.6.
I’ve tried adding theme support and the js file, but as you mentioned earlier, it also needs ajax.php to do the work. (I don’t know how to make that happen.)
Thanks,
-David
Hi Hugo-
I came across this comment on trac that appeared to be in the wrong place but sounded similar to my problem: https://buddypress.trac.wordpress.org/ticket/4869#comment:17
I’ve found that if I install Boone’s GitHub version of the template pack and only enable the JS file portion of it, it works (if my buddypress templates are back at the root of the theme, not in a buddypress folder).
Is there a better way? (I’m also concerned that 1.7 is going to unexpectedly break a number of customized themes like mine.) What’s funny about this is that with 1.6 I used the template pack, then deactivated it while working with 1.7-beta, but it appears that I need it again.
Thanks for your help,
-David
Hi Hugo-
Thanks for following up. The theme was built against BP1.6 & 1.7-beta, so the buddypress-related template folders (activity, blogs, groups, etc) were in the root of the theme. This resulted in the theme being rendered correctly, but, with BP1.7, the js support disappeared.
I’ve moved the bp-related folders into a “buddypress” folder at the root of the theme (as described in your article: https://codex.buddypress.org/developer/theme-development/a-quick-look-at-1-7-theme-compatibility/). Moving the files causes the output to be garbled. For instance, on a single member’s profile page, a div#content is being created inside of the div#content provided in the main template `buddypress.js`, and, while the object-nav (activity, messages, etc) is being rendered, the header and the main content area aren’t being populated. Structurally, it’s like the entire buddypress output is being wrapped in the theme’s page template. But not completely, because the end of the file isn’t being rendered.
As you can tell, I’m not exactly sure what’s going on. 🙂
Thanks again for your advice,
-David
Hi Hugo-
Thanks for your reply. I’m not doing anything to prevent theme compat from running (as far as I know–I thought that add_theme_support(‘buddypress’) was the flag to stop compat, and I’m not setting that).
Basically, I’ve provided php and css files via my theme but would like the js bits to continue to be provided by BP.
I thought I understood how theme compat worked via the 1.7-betas (my theme behaved just like it did under 1.6.x), but it seems to be different with the actual release.
Is there a document somewhere describing what triggers/short-circuits theme compat, so I can know either how to get BP to provide the theme compat via js, or, alternatively, duplicate the right files from bp-default into my theme to get the functionality back?
Thanks again for your reply,
-David
Should have mentioned: Using WP 3.5.1 with BP 1.7. This is on a closed dev site (production site is still running 1.6.x perfectly, so I’m not freaking out or anything.) Thanks again for your help.
I’d try flushing the permalinks settings.
Visit the WP admin dashboard > Settings > Permalinks. Don’t change anything, but click “Save Changes.” This will refresh the permalinks, and in many cases, straighten out the problem you’re having.
-David
Also consider the honey pot method. It catches automated spammers but not human spammers.
https://github.com/pixeljar/BuddyPress-HoneypotFor human spammers you almost need to approve each user request. Which is a pretty big barrier to entry, I think. I’ve used this plugin to do that:
https://wordpress.org/extend/plugins/bp-registration-options/You can use BuddyPress Humanity to stop bots:
https://wordpress.org/extend/plugins/buddypress-humanity/or the honey pot method: https://github.com/pixeljar/BuddyPress-Honeypot
If necessary, you can manually approve users:
https://wordpress.org/extend/plugins/bp-registration-options/