Forum Replies Created
-
In reply to: How make full widthIn reply to: bbp_reply_admin_links
hmmm … if you want each link to be a button, I can point you to some code, but you’ll need to figure it out.
so
so for replies, the function is in
bbpress/includes/replies/template.php
which I think you found.
function bbp_get_reply_admin_links( $args = array() ) { // Parse arguments against default values $r = bbp_parse_args( $args, array( 'id' => 0, 'before' => '<span class="bbp-admin-links">', 'after' => '</span>', 'sep' => ' | ', 'links' => array() ), 'get_reply_admin_links' ); $r['id'] = bbp_get_reply_id( (int) $r['id'] ); // If post is a topic, return the topic admin links instead if ( bbp_is_topic( $r['id'] ) ) { return bbp_get_topic_admin_links( $args ); } // If post is not a reply, return if ( !bbp_is_reply( $r['id'] ) ) { return; } // If topic is trashed, do not show admin links if ( bbp_is_topic_trash( bbp_get_reply_topic_id( $r['id'] ) ) ) { return; } // If no links were passed, default to the standard if ( empty( $r['links'] ) ) { $r['links'] = apply_filters( 'bbp_reply_admin_links', array( 'edit' => bbp_get_reply_edit_link ( $r ), 'move' => bbp_get_reply_move_link ( $r ), 'split' => bbp_get_topic_split_link( $r ), 'trash' => bbp_get_reply_trash_link( $r ), 'spam' => bbp_get_reply_spam_link ( $r ), 'reply' => bbp_get_reply_to_link ( $r ) ), $r['id'] ); } // See if links need to be unset $reply_status = bbp_get_reply_status( $r['id'] ); if ( in_array( $reply_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id() ) ) ) { // Spam link shouldn't be visible on trashed topics if ( bbp_get_trash_status_id() === $reply_status ) { unset( $r['links']['spam'] ); // Trash link shouldn't be visible on spam topics } elseif ( bbp_get_spam_status_id() === $reply_status ) { unset( $r['links']['trash'] ); } } // Process the admin links $links = implode( $r['sep'], array_filter( $r['links'] ) ); $retval = $r['before'] . $links . $r['after']; return apply_filters( 'bbp_get_reply_admin_links', $retval, $r, $args ); }which you can filter at the end, but how would depend on your skills.
the span part can be simply changed by putting a filter into your child theme’s function file
eg
add_filter ('bbp_before_get_reply_admin_links_parse_args', 'theredeclipse_change' ) ; function theredeclipse_change ($args) { $args['before'] = '<span class="bbp-admin-links">' ; $args['after'] = '</span>' ; return $args ; }and just change whatever you want the span part to look like, or just remove it.
if you want to style each link, then you’ll see that there is a call to each separate function
'edit' => bbp_get_reply_edit_link ( $r ), 'move' => bbp_get_reply_move_link ( $r ), 'split' => bbp_get_topic_split_link( $r ), 'trash' => bbp_get_reply_trash_link( $r ), 'spam' => bbp_get_reply_spam_link ( $r ), 'reply' => bbp_get_reply_to_link ( $r )so to do it in functions, you’d need to go to each one.
you’ll find these in the same file above
since the class is hard coded, you could add a final filter with a preg_replace
eg
add_filter( 'bbp_get_reply_move_link' , 'theredeclipse_move', 10 , 2 ) ; function theredeclipse_move ($retval, $r) { $retval = preg_replace(whatever args you need, with, $retval); return $retval ; }so $retval will hold the line of code including the class.
so google preg-replace and see if you can get it working !!
In reply to: Help with dynamic button positioningdo you know how to put functions into your theme’s function file?
In reply to: Different user for WordPress and bbpressbecause bbpress uses the wordpress login, you can’t have two logins on the same domain.
So your best bet would be to say to people
use the ‘world’ login for everyone, but individuals swap to an individual login and only use that once they have been given an individual that is all they use.
In reply to: bbp_reply_admin_linksnot quite sure what you are asking.
If you just want to style, then you would use css rather than php. If you want to change what they do, then you would use php
Can you come back and explain with a specific example what you want to do.
eg I want x to look like this, or do that
In reply to: Different user for WordPress and bbpressyou could use my private groups plugin.
https://wordpress.org/plugins/bbp-private-groups/
you would create two groups
1. called say all
2. called say individualsyou can then put all the forums as members of the individual group, but no forums would have the world group.
Then all individual users would be added to the individuals group.
Then anyone logging in with the world username would not see any forums, but when logging in as individuals they would see the forums.
In reply to: Deleting BBpress websitethat’s not a bbpress page, looks like it might be a version 1 site
In reply to: 2 User Names with one Role Capabilitycan you paste the exact code you are using into here, and I’ll check it
In reply to: 2 User Names with one Role Capabilityfollow this link with a description on how to do this
In reply to: Allow Participants to Trash / own Topics and Postsno problem – was a fun challenge once I had started !!
In reply to: Forum descriptionsshould be fixed in 3.4.9 just released
In reply to: Forum topic issueit may be a conflict ot it could be a theme or plugin issue
Plugins
Deactivate all but bbpress and see if this fixes. if it does, re-enable one at a time to see which is causing the error.
Themes
If plugins don’t pinpoint the problem, as a test switch to a default theme such as twentyfifteen, and see if this fixes.
Then come back
In reply to: Allow Participants to Trash / own Topics and Postsok, this code allows participabts to
trash their own replies and
trash their own topics where there have been no replies, once a reply has been posted then they can no longer delete.it does display slightly weirdly when you delete a topic, but it is the best you are going to get from me.
give it a try and see if you still have the admin problems
/*Customize the BBPress roles to allow Participants to trash topics*/ add_filter( 'bbp_get_caps_for_role', 'ST_add_role_caps_filter', 10, 2 ); function ST_add_role_caps_filter( $caps, $role ){ // Only filter for roles we are interested in! if( $role == bbp_get_participant_role() ) { $newcaps = array( // Primary caps 'spectate' => true, 'participate' => true, // Forum caps 'read_private_forums' => true, // Topic caps 'publish_topics' => true, 'edit_topics' => true, 'delete_topics' => true, 'view_trash' => true, // Reply caps 'publish_replies' => true, 'edit_replies' => true, 'delete_replies' => true, // Topic tag caps 'assign_topic_tags' => true, ); return $newcaps; } return $caps; } add_filter( 'bbp_map_reply_meta_caps', 'ST_tweak_trash_meta_caps', 11, 4 ); add_filter( 'bbp_map_topic_meta_caps', 'ST_tweak_trash_meta_caps', 11, 4 ); function ST_tweak_trash_meta_caps( $caps, $cap, $user_id, $args ){ // apply only to delete_reply and delete_topic if ( $cap == "delete_reply" || $cap == "delete_topic" ){ // Get the post $_post = get_post( $args[0] ); if ( !empty( $_post ) ) { // Get caps for post type object $post_type = $_post->post_type ; // Add 'do_not_allow' cap if user is spam or deleted if ( bbp_is_user_inactive( $user_id ) ) { $caps[] = 'do_not_allow'; // Moderators can always edit forum content } elseif ( user_can( $user_id, 'moderate' ) ) { $caps[] = 'moderate'; // User is particiapte so allow delete } elseif ( user_can( $user_id, 'participate' ) && ( (int) $user_id === (int) $_post->post_author ) ) { //allow any reply to be deleted if ($post_type == bbp_get_reply_post_type()) $caps = array('delete_replies') ; //only allow topic delete if there are no replies if ($post_type == bbp_get_topic_post_type()) { $reply_count = bbp_get_topic_reply_count(); if ( $reply_count == 0) $caps = array('delete_topics') ; } // Unknown so do not allow } else { $caps[] = 'do_not_allow'; } } } // return the capabilities return $caps; }In reply to: Allow Participants to Trash / own Topics and Postsdeleting replies will redirect to the topic that still exists, so that will work!
deleting topics redirects to the topic which no longer exists, so gets a 404 error which your site directs to the homepage – not sure how to fix that. A moderator can still view the topic, so that is ok. might be able to do some code with a readtopics capability so that an author can view his own closed topics.
on admins – Sorry I still don’t quite understand.
1. so I have a browser tab logged into admin, and showing the dashboard. I then open another tab in the same browser and paste in a forums link and it goes to the homepage – yes ?
2. if so – I can’t replicate
3. Why do you need to do this?In reply to: /Forum and forum link in wp backend not workingI think you have done so much on the current site that it is impossible to say what is wrong.
I think you need to create a totally fresh site, and start again with just a standard theme (say twentyfifteen) and bbpress.
Then build form there.
In reply to: Forum Root Issue@ellencrombie – did this work?
In reply to: Allow Participants to Trash / own Topics and Postson the first one, can you clarify that accessing
dashboard>forums just sends you to the homepage, or can you tell me exactly what actions are needed.
In reply to: Allow Participants to Trash / own Topics and Postsok, whilst out I think I know what the issue is.
Firstly can you confirm that apart from redirecting you to home, the code at the top of this thread works? ie redirection to the wrong place is the only outstanding issue.
If so, the issue is that after you delete a topic, bbpress sends you to back to the topic, which as a moderator you are allowed to see trashed topics, but as a partyicipant you are not. This then will send you to a 404 page, which in your case I think just sends you to home.
So let me look at ways to get around this.
In reply to: Forum descriptionsthanks – I’ll take a look
In reply to: Allow Participants to Trash / own Topics and Poststhough re-reading the thread this morning, I think I have not fixed anything, juts done it another way.
and that doesn’t work either – forget the code above
In reply to: Allow Participants to Trash / own Topics and Postsok, I’ve taken pity and kicked this round for an hour – I expect to be on your Christmas list !!!
This seems to work, although please do some testing for all roles, and check it out.
/*Customize the BBPress roles to allow Participants to trash topics*/ add_filter( 'bbp_get_caps_for_role', 'ST_add_role_caps_filter', 10, 2 ); function ST_add_role_caps_filter( $caps, $role ){ // Only filter for roles we are interested in! if( $role == bbp_get_participant_role() ) { $caps = array( // Primary caps 'spectate' => true, 'participate' => true, // Forum caps 'read_private_forums' => true, // Topic caps 'publish_topics' => true, 'edit_topics' => true, 'delete_topics' => true, // Reply caps 'publish_replies' => true, 'edit_replies' => true, 'delete_replies' => true, // Topic tag caps 'assign_topic_tags' => true, ); } return $caps; } /*then only allow participants to trash their own topics*/ add_filter( 'bbp_map_reply_meta_caps', 'ST_tweak_trash_meta_caps', 11, 4 ); add_filter( 'bbp_map_topic_meta_caps', 'ST_tweak_trash_meta_caps', 11, 4 ); function ST_tweak_trash_meta_caps( $caps, $cap, $user_id, $args ){ // apply only to delete_reply and delete_topic if ( $cap == "delete_reply" || $cap == "delete_topic" ){ // Get the post $_post = get_post( $args[0] ); if ( !empty( $_post ) ) { // Get caps for post type object $post_type = get_post_type_object( $_post->post_type ); //$caps = array(); // Add 'do_not_allow' cap if user is spam or deleted if ( bbp_is_user_inactive( $user_id ) ) { $caps[] = 'do_not_allow'; // Moderators can always edit forum content } elseif ( user_can( $user_id, 'moderate' ) ) { $caps[] = 'moderate'; // User is author so allow edit if not in admin } elseif ( user_can( $user_id, 'participate' ) && ( (int) $user_id === (int) $_post->post_author ) ) { $caps = array(); //$caps[] = $post_type->cap->delete_posts; // Unknown so do not allow } else { $caps[] = 'do_not_allow'; } } } // return the capabilities return $caps; }In reply to: Forum topic issuecan you tell us
what theme you are using
what other plugins you are usingIn reply to: Searching across forumsno problem – not so long ago I was a newbie !!
In reply to: Searching across forumsthe bbpress search widget does that – is there something particular that you want?
In reply to: Change queryI am not sure I understand what it is you are asking
wp-query is a wordpress function