Search Results for 'code'
-
AuthorSearch Results
-
October 14, 2018 at 7:47 pm #195497
In reply to: How to set limits on the number of replies to topics
eigodeasobo
ParticipantHi,
Unfortunately, it didn’t work out.add_action( 'bbp_new_reply_post_extras', 'rew_close_topic' ); function rew_close_topic ($reply_id) { // find out the topic_id $topic_id = bbp_get_reply_topic_id ($reply_id) ; $count = bbp_get_topic_reply_count ($topic_id) ; if ($count >9) bbp_close_topic( $topic_id ); }If you have further information, please let me know.
Thanks.October 14, 2018 at 12:08 pm #195495In reply to: Create/add forum from frontend
Robin W
Moderatorthe screenshot says that you are using buddypress and the buddypress profile as well, and that code is just for bbpress.
If you paste your reply immediately above on the buddypress support site, someone should be able to tell you the correct add_action to hook to buddypress profile
October 14, 2018 at 9:35 am #195492In reply to: Create/add forum from frontend
inderpreet2018
ParticipantOctober 14, 2018 at 5:49 am #195489In reply to: Create/add forum from frontend
Robin W
Moderatorthe issue is with the ‘ the code has been copied via another program and is using the wrong ones
copy this below
function ntwb_bbp_forum_form() { if ( bbp_is_user_home() && current_user_can( 'moderate' ) ) { echo do_shortcode( '[bbp-forum-form]' ); } } add_action( 'bbp_template_after_user_profile', 'ntwb_bbp_forum_form' );the form is shown on the moderators profile
October 14, 2018 at 4:57 am #195485Topic: Create/add forum from frontend
in forum Pluginsinderpreet2018
ParticipantHi,
I used below code to add forum from frontend for Moderator user in my child-theme function file, but nothing works and showed on frontend.
function ntwb_bbp_forum_form() {
if ( bbp_is_user_home() && current_user_can( ‘moderate’ ) ) {
echo do_shortcode( ‘[bbp-forum-form]‘ );
}
}
add_action( ‘bbp_template_after_user_profile’, ‘ntwb_bbp_forum_form’ );Please help me to sort out this.
October 13, 2018 at 5:35 pm #195480In reply to: Struggling with login
Robin W
Moderatorok, so using bbp-style pack (so make sure it is activated)
In
dashboard>settings>bbp Style pack>login
set both
Login menu item css class and Logout menu item css classto
aadthen go to
dashboard>settings>bbp Style pack>custom css and put this in there
.aad { margin-top: 11.9px; }if that doesn’t work, leave the code in there and come back
October 13, 2018 at 9:12 am #195474Topic: Can’t give users custom roles.
in forum Troubleshootingankylol
ParticipantHello,
Robin i added the tutor code to my functions file.As you can see in this link –> https://prnt.sc/l5mmhh i can see the role while editing users forum role.But the thing is when i try to give the user that Tutor role and save user profile.The forum role of the user is being -No roles for this forums- so i can’t give the custom role. Also i tried the other custom name functions thing.I created a role and gived it participant perms but couldn’t give that role to user too.
October 13, 2018 at 12:42 am #195470In reply to: Custom Topic Statuses?
John James Jacoby
KeymasterThis will be easier to do in bbPress 2.6. A bunch of hooks were added to the codebase to make status manipulation possible in many ways it was not previously.
October 12, 2018 at 12:34 pm #195460In reply to: sticking a reply at the top of the repies
Robin W
ModeratorIf you fine with code, then this is how I would go about it
1. create a split in topic & replies, so you have a place to put the ‘featured reply’
Use this piece of code in your functions file2. then you’ll need a flag for the featured reply.
This code does an ‘advert’ flag for a topic, but has much of the code you’d need to do a flag for a reply to show it is featured – I’ll leave you to work out which bits you’ll need, but the key is the hook to
add_action( 'bbp_theme_before_topic_form_submit_wrapper', 'at_checkbox' );change this to
add_action( 'bbp_theme_before_reply_form_submit_wrapper', 'at_checkbox' );amend the references from topic to reply
and add some if(bbp_keymaster() ) to make it only show for you, and you will be most of the way there
// show the "Mark if it is an advert" checkbox on topic form add_action( 'bbp_theme_before_topic_form_submit_wrapper', 'at_checkbox' ); function at_checkbox() { // Text for the topic form global $topic_advert_text ; ?> <p> <input name="at_advert" id="at_advert" type="checkbox"<?php checked( '1', at_is_advert( bbp_get_topic_id() ) ); ?> value="1" tabindex="<?php bbp_tab_index(); ?>" /> <?php if ( bbp_is_topic_edit() && ( get_the_author_meta( 'ID' ) != bbp_get_current_user_id() ) ) : ?> <label for="at_advert"><?php echo '<span class="dashicons dashicons-awards"></span>'.$topic_advert_text.'</label>' ;?> <?php else : ?> <label for="at_advert"><?php echo '<span class="dashicons dashicons-awards"></span>'.$topic_advert_text.'</label>' ;?> <?php endif; ?> </p> <?php } //check if topic is advert function at_is_advert( $topic_id = 0 ) { $retval = false; if ( ! empty( $topic_id ) ) { $retval = get_post_meta( $topic_id, 'at_topic_is_advert', true ); } return (bool) apply_filters( 'at_is_advert', (bool) $retval, $topic_id ); } // save the advert state add_action( 'bbp_new_topic', 'at_update_topic' ); add_action( 'bbp_edit_topic', 'at_update_topic' ); //update topic function at_update_topic( $topic_id = 0 ) { if( isset( $_POST['at_advert'] ) ) update_post_meta( $topic_id, 'at_topic_is_advert', '1' ); else delete_post_meta( $topic_id, 'at_topic_is_advert' ); }3. amend content-single-topic-lead.php in your child theme’s bbpress directory.
by
create a directory on your theme called ‘bbpress’
ie wp-content/themes/%your-theme-name%/bbpresswhere %your-theme-name% is the name of your theme
find
wp-content/plugins/bbpress/templates/default/bbpress/content-single-topic-lead.php
Make a copy of this file, and put in in the directory called bbpress that you created above, so you end up with
wp-content/themes/%your-theme-name%/bbpress/content-single-topic-lead.phpbbPress will now use this template instead of the original and you can amend thisThis then you can use to add some code
if (at_is_advert( $reply_id )) then….. display this reply
and you should be there
so
the reply form will show a checkbox to make a reply featured available only to say keymaster, and as keymaster you can edit a topic to make it a featured
the content_single_topic_lead will check if a reply is featured and then show it if it isI wish I had the time to code this all for you, but please if you do work oyt some code, post back here for other to benefit
October 12, 2018 at 4:33 am #195445Sociality
ParticipantHi there I had the same problem and I used this solution that does not use buddypress. The sanitize title I use if for greek so I do not post it here but you should use something for sure.
//This is used to hide the username from the profile url function tpp_forum_profile_url( $user_id, $old_values) { $user = get_user_by( 'ID', $user_id ); $display_name = $user->data->display_name; if ( $user ) { if ( $user->data->user_status == 0 && $display_name ) { $new_user_nicename = tpp_sanitize_title($display_name ); if ( strlen ( $new_user_nicename ) > 50 ) { $new_user_nicename = substr ( $new_user_nicename, 0, 50 ); } if ( $user->data->user_nicename != $new_user_nicename ) { $args = array( 'ID' => $user->ID, 'user_nicename' => $new_user_nicename ); wp_update_user( $args ); wp_redirect( get_site_url().'/forums/user/'.$new_user_nicename.'/edit/' ); exit; } } } } add_action( 'profile_update', 'tpp_forum_profile_url', 100, 5 );October 12, 2018 at 3:43 am #195442In reply to: Custom Topic Statuses?
Robin W
Moderatorbbpress does not do custom topic statuses, so they are coming from that support plugin, best post there as it is that plugin that needs to work with 2.6, but most plugin authors do not code for pre-release software as it changes.
October 12, 2018 at 3:40 am #195441In reply to: How to set limits on the number of replies to topics
Robin W
Moderatorok, I cannot say why it is not working, it works in my test site
I presume this code is going into you child theme’s function’s file – sorry but I do not know how technical you are, so I ask the obvious questions !
you could try >9 and see if that works !
October 12, 2018 at 3:33 am #195440In reply to: How to set limits on the number of replies to topics
eigodeasobo
ParticipantI changed that number from 100 to 10 and posted over 11 replies.
if ($count == 100) bbp_close_topic( $topic_id );
↓
if ($count == 10) bbp_close_topic( $topic_id );However, it was not closed.
Thanks.
October 12, 2018 at 2:45 am #195438In reply to: How to set limits on the number of replies to topics
Robin W
Moderatorthat code will close the topic on 100 replies, so unless you tested with creating the 100th reply, then it would not work. Did you do this ?
October 11, 2018 at 7:29 pm #195428In reply to: How to set limits on the number of replies to topics
eigodeasobo
ParticipantHi, Thanks for the reply.
But that code did not close.
So, I wrote the following code for now.
<p id="replies_count"><?php bbp_topic_reply_count(); ?></p> <script> (function($){ var replies_count = $('#replies_count').text(); if( replies_count >= 100 ){ $('.bbp-reply-to-link').css('display','none'); } })(jQuery); </script>However, It’s incomplete just because it is hidden, so I would like to close it as well.
Please let me know again if there is another code.
Thanks.
October 11, 2018 at 4:13 pm #195424In reply to: sticking a reply at the top of the repies
Robin W
Moderatorthat would take a lot of code, beyond free help
October 11, 2018 at 1:56 pm #195419In reply to: How to set limits on the number of replies to topics
Robin W
Moderatoradd this to your functions file, it closes the topic when the 100th reply is posted
add_action( 'bbp_new_reply_post_extras', 'rew_close_topic' ); function rew_close_topic ($reply_id) { // find out the topic_id $topic_id = bbp_get_reply_topic_id ($reply_id) ; $count = bbp_get_topic_reply_count ($topic_id) ; if ($count == 100) bbp_close_topic( $topic_id ); }October 11, 2018 at 1:25 pm #195416In reply to: How to query replies by topics
Robin W
ModeratorNo idea from your post of what code you are trying.
bbp_has_replies is the function you need for the loop
October 11, 2018 at 12:43 pm #195412In reply to: Changing the first item on a topic list
Robin W
Moderatorthe default is false, so it would do nothing – you should be using
$show_lead[] = 'true';then it will use the template it talks about and you can style it
October 11, 2018 at 11:31 am #195411In reply to: Changing the first item on a topic list
jd-fb
ParticipantThanks again, Robin!
I’ve successfully used the code above to modify the templates. Woo!However, one question / comment:
The code you’ve provided for bbp_show_lead_topic doesn’t seem to do anything for me.
I’ve tried:function custom_bbp_show_lead_topic( $show_lead ) { $show_lead[] = 'false'; // The code as shown on https://codex.bbpress.org/bbp_show_lead_topic/ $show_lead[] = false; // No quotation marks around 'false' $show_lead = false; // no array [] used on $show_lead, no quotation; $show_lead = 'false' // no array, with quotation return $show_lead; }And none of these seemed to change how the lead topic was displayed.
But, I’ve figured out the templates and I’m getting the results I was hoping for.Thanks again.
October 11, 2018 at 3:28 am #195406In reply to: Subscribe – Post Author Not Receiving Email
Robin W
Moderatorthe function that bbpress uses is in
includes/common/functions.php
line 1055 starts the function, and lines 1150 to 1153 are the offending ones which stop it being sent to the author
I’d suggest you unhook that function and then hook your own
so in your child theme functions file maybe have
remove_action( 'bbp_new_reply', 'bbp_notify_topic_subscribers', 11, 5 ); add_action ( 'bbp_new_reply' , 'rew_notify_topic_subscribers', 11,5 ) ;and then copy the whole bbp_notify_topic_subscribers function to your functions file, rename it to ‘rew_notify_topic_subscribers’ and edit out the lines which stop it being sent to the author
do come back if anything isn’t clear, I’m assuming a level of knowledge you may not have, and quite happy to help further
October 10, 2018 at 1:59 pm #195400Topic: How to set limits on the number of replies to topics
in forum Troubleshootingeigodeasobo
ParticipantHi,
I’d like to restrict the reply to 100 cases, but is there a way?
For example, I want to make it
.bbp-reply-to-link{display:none;}when comment becomes 100 or more.However, since only 15 replies are displayed on one page, JS can not count comments on loading.
So, It’s best if you can do that with PHP settings…
What should I do?
Thanks.
October 9, 2018 at 10:04 pm #195378In reply to: Delete Post by It’s Owner
inderpreet2018
ParticipantHi,
I used above code/plugin to add delete_topics in capabilities for participant and it doesn’t work.
Can you help me, how I allow users trash their own topics?
Thanks
October 9, 2018 at 4:29 pm #195377In reply to: Subscribe – Post Author Not Receiving Email
Robin W
Moderatoryes, that is the default position, I’ll try and work out some code in the next few days.
If I have not come back in 3 days time, post again to remind me !
October 9, 2018 at 4:26 pm #195375In reply to: Message on the text editor: CONTENT string (0)
Robin W
Moderatorsomething is putting that code there, you will need to work out what
It could be a theme or plugin issue issue, so you’ll need to test to find out which
Themes
As a test switch to a default theme such as twentyfifteen, and see if this fixes.
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.
Then come back
-
AuthorSearch Results

