Search Results for 'code'
-
AuthorSearch Results
-
July 10, 2022 at 1:37 pm #230283Robin WModerator
ok,
1. create a page called ‘profile’, it needs no content, but make sure the permalink is ‘profile’
2. in dashboard>settings>wp members>pages>profile select the profile pagethen use this code
add_action( 'template_redirect' ,'rew_profile' ) ; function rew_profile () { update_option ('rewurl' , $_SERVER['REQUEST_URI'] ) ; if ($_SERVER['REQUEST_URI'] == '/profile/') { $user_id =get_current_user_id() ; $url = bbp_get_user_profile_url( $user_id ) ; exit( wp_redirect( $url ) ); } }
Put this in your child theme’s function file –
ie wp-content/themes/%your-theme-name%/functions.php
where %your-theme-name% is the name of your theme
or use
July 10, 2022 at 12:23 pm #230281gtatarParticipantThank you, Robin. I added the snipped, and it partially worked. The anchor text “time ago” now reflects the time of the latest good post. However the URL is for the latest spam post.
I started digging a bit through bbpress code. It looks like if the fix was inside bbp_topic_freshness_link() it would be much easier to test, as we would not need to wait for a new spam post to test the fix. And perhaps make decisions based on the wp_post status having the value “publish”. This way the solution would not be specific to Akismet. But I am really too new to WordPress coding and bbPress to be making this kind of changes myself.
July 10, 2022 at 11:42 am #230280Robin WModeratorif it works for a topic, then I’ll do the code for a reply, which is basically changing mthe word topic to reply 🙂
July 10, 2022 at 11:38 am #230279Robin WModeratorok, give this a try – it may or may not do the trick !!
add_action ('bbp_new_topic_post_extras', 'rew_spam_update_last_active', 10 ,1 ) ; function rew_spam_update_last_active ($topic_id) { //this function tests if a new topic has been marked as spam by Akismet. If so then the last active date will be wrong //So we use topic walker to recalculate it if (!empty (get_post_meta( $topic_id, '_bbp_akismet_user_result' ))) { bbp_update_topic_walker ($topic_id) ; } }
Put this in your child theme’s function file –
ie wp-content/themes/%your-theme-name%/functions.php
where %your-theme-name% is the name of your theme
or use
July 10, 2022 at 3:18 am #230274Robin WModeratoryes it does (and does so on here as well!).
I’m just a helper here, not a bbpress author.
I don’t run akismet on my test site. Are you able to replicate the problem so that we can check a fix if I am able to work up some code?
July 7, 2022 at 1:41 pm #230255In reply to: @mentions for bbpress
saltywdParticipantHello Robin, Thanks for the quick reply. I have that plugin but it doesnt seem to work at all. I cant even see that it has any settings anywhere. I do have active right now, WP with Avada Theme, BBPress, bbp Style pack, bbpress notify, GD bbpress Attachments, and Ultimate Member and a few of its extensions for bbpress as it is a private forum.
on bbp style pack there is a check box to make @mentions help, but says you need buddypress or bbp-mentions-email-notifications which I have tried that plugin and it doesnt work either.
Would love to use your plugin but i cant get it to work at all.
I see on GIST there is some code for a bp-custom.php file which includes this
<?php /** You could put this in the bp-custom.php file * @see https://codex.buddypress.org/themes/bp-custom-php/ */ function custom_bbpress_maybe_load_mentions_scripts( $retval = false ) { if ( function_exists( 'bbpress' ) && is_bbpress() ) { $retval = true; } return $retval; } add_filter( 'bp_activity_maybe_load_mentions_scripts', 'custom_bbpress_maybe_load_mentions_scripts' );
July 6, 2022 at 5:29 am #230234In reply to: bbPress single topic + Elementor
rinhParticipantMy post disappeared and I’m unable to post it again: I’ll try again
I messed around with the conditions in the theme builder last night and I found working solutions 🙂
Elementor template for single topic and single forum
This template will work for single topics (those pages where you read a topic and can reply) and single forum (where you see a list of topics, sometime called boards or category). Both of these act as single posts. Make a Single post template according to your needs and in the container/section where you want bbPress itself put an Archive Posts widget and set the skin to Full Content. It’s going to look like your blog posts in Elementor editor, but it’s normal.
Save the template with the following conditions:
Include: All Singular
Exclude: Posts (unless you want the same template for your posts)
Exclude: any custom post types you may have
Exclude: Pages (just to be safe)
Exclude: you may need to exclude additional things according to your needs.Elementor template for forum index
This template will work for the forum index only. Create and Archive template according to your needs. In the container/section where you want bbPress itself put bbPress forum index shortcode which can be found here: https://codex.bbpress.org/features/shortcodes/
Save the template with the following conditions:
Include: Forums Archive
July 6, 2022 at 3:11 am #230227In reply to: How to edit forum user role compatibilities?
Robin WModeratorJuly 5, 2022 at 8:19 am #230209In reply to: Edit Topic Page
wdseocompanyParticipantHi Robin,
Thanks for the info on this one; I’ve managed to get this resolved. In essence I was overcomplicating the problem.I disabled the templates I had setup so the page could just return all the default content and the edit functionality was working. Instead of using the custom code snippet I just used the ‘Post Content’ module in Divi which worked beautifully.
Coming back to it with a fresh set of eyes and taking it back to basics helped a lot haha!
Thanks again Robin for your help, all the best!
Kind regards,
Matt PJuly 3, 2022 at 3:53 am #230174In reply to: Topic submission form customisation
Robin WModeratorso you are happy that in the forum display, the topic content box will be there, but show nothing ?
for 1,3&4
#bbpress-forums fieldset.bbp-form input[type="text"] { width: 100% !important; } div.bbp-submit-wrapper { width: 100%; }
add this to the custom css of your theme
July 2, 2022 at 1:21 pm #230169Robin WModeratorok, I’ve found time to take an initial look at this.
The function called looks at a database item which holds the sub forum count – but it looks like this is just count of public forums, so the count is zero, so none displayed.
so removing looking at this takes away the issue.
It would take a deal of work to see why and how to make a permanent fix to this, and I think this filter will do what you want
add_filter('bbp_forum_get_subforums', 'rew_forum_get_subforums', 10, 3); function rew_forum_get_subforums( $sub_forums, $r, $args ) { // Default return value $retval = array(); // Use passed integer as post_parent if ( is_numeric( $args ) && ! empty( $args ) ) { $args = array( 'post_parent' => bbp_get_forum_id( $args ) ); } // Parse arguments against default values $r = bbp_parse_args( $args, array( 'post_parent' => 0, 'post_type' => bbp_get_forum_post_type(), 'posts_per_page' => get_option( '_bbp_forums_per_page', 50 ), 'orderby' => 'menu_order title', 'order' => 'ASC', 'ignore_sticky_posts' => true, 'no_found_rows' => true ), 'forum_get_subforums' ); // Ensure post_parent is properly set $r['post_parent'] = bbp_get_forum_id( $r['post_parent'] ); // Query if post_parent has subforums if ( ! empty( $r['post_parent'] ) ) { $get_posts = new WP_Query(); $retval = $get_posts->query( $r ); } // Filter & return return (array) apply_filters( 'rew_forum_get_subforums', $retval, $r, $args ); }
Put this in your child theme’s function file –
ie wp-content/themes/%your-theme-name%/functions.php
where %your-theme-name% is the name of your theme
or use
July 2, 2022 at 9:26 am #230167Robin WModeratorThis is not fully tested, but should work
add_filter( 'bbp_get_reply_edit_url', 'rew_admin_link', 10 , 2 ) ; function rew_admin_link ($url, $reply_id ) { if ( bbp_is_user_keymaster(get_current_user_id())) { $url = '/wp-admin/post.php?post='.$reply_id.'&action=edit' ; } return $url ; }
June 30, 2022 at 11:46 pm #230140In reply to: HTML editor doesn’t appear on bbpress 2.6.7
scmsteveParticipantWe are also seeing this, it took quite a while to track it down to this. Adding the code provided here seems to make the editor visible/work again.
Another issue we are having, though, is the display of emoticons or whatever they are called that were inserted via TinyMCE…
We get a 404 error on the URL formed like this:
/forum/my-plugins/tiny_mce/plugins/emotions/img/smiley-smile.gif
June 30, 2022 at 6:23 am #230132In reply to: Profile pictures on an angle like bbPress
neon67Participantadd to css
transform: rotate(5deg) translateY(-10%); transform-origin: top left;
June 29, 2022 at 5:52 pm #230121coopersitaParticipantThanks. I actually rolled my own solution with the post anonymously checkbox. I’m not too concerned that people will post with their names by mistake and be too upset. Here’s the code I’m using in case someone else is looking. For this setup to work, you just need to create an “anonymous’ user, so all topics that are flagged will be attributed to the user and the original user id is saved as a meta field so the system isn’t abused (so mostly anonymous, but not completely):
//Anonymous publishing in forums //add fields to form (checkbox) add_action ( 'bbp_theme_after_topic_form_content','bbp_extra_fields'); //save fields and change author add_action ( 'save_post_topic', 'bbp_save_extra_fields', 10, 2); //display original author for admins above topic add_action('bbp_template_before_replies_loop', 'bbp_show_extra_fields'); function bbp_extra_fields() { $value = get_post_meta( bbp_get_topic_id(), 'is_anonymous', true); echo "<input type='checkbox' name='is_anonymous' id='is_anonymous' value='yes' ".checked('yes', $value)."> "; echo '<label for="is_anonymous">Post this topic anonymously</label>'; echo '<p><strong>Note:</strong> By checking this box, your identity will be hidden from other participants, but not from moderators nor admins. </p>'; } function bbp_save_extra_fields( $post_id, $post) { if(isset($_POST['is_anonymous']) && $_POST['is_anonymous'] === 'yes') { $anon_ID = 1; // Id of dedicated anonymous user // update post if it's not anonymous already if($post->post_author != $anon_ID) { update_post_meta($post_id, 'is_anonymous', $post->post_author); wp_update_post( array( 'ID' => $post_id, 'post_author' => $anon_ID ) ); } } } function bbp_show_extra_fields() { if(current_user_can('delete_others_topics')) { $topic_id = bbp_get_topic_id(); $anon_author = get_post_meta( $topic_id, 'is_anonymous', true); if($anon_author) { $user = get_user_by('ID', intval($anon_author)); if($user) { echo "Original Author: <a href='".site_url()."/forums/users/".$user->user_login."'>".$user->display_name."</a><br>"; } } } }
The code is only for posting topics. I’m not sure if for my use case replies would also need to be anonymous. We mostly want people to be able to ask questions openly without fear of being recognized by their peers (some users know each other).
June 29, 2022 at 4:29 pm #230115Robin WModeratorAlternatively, is there a way to post completely anonymously, but in a way that is available only for logged-in users?
I think you’ve asked this before, but not sure I responded.
It is technically possible, but lots of code and beyond free help. In any case I’d suspect that someone would post thinking it was anonymous, but forget to tick the box that says anonymous, or use the wrong form, and by mistake post something outrageous that then appears in their name, cue them accusing your site of destroying their reputation, you accusing whoever wrote the code of it not being robust, and all hell breaking loose. So not code that I would write.
your other suggestion is also possible, but you’d need to catch everywhere the username is used, and again risk it being exposed in some code that isn’t expected.
I s’pose my gut answer is just enable anonymous posting, and use the ‘hold for moderation’ in the moderation part of my style pack plugin to approve anonymous posts. Then tell your users that they must log out to post anonymously.
June 29, 2022 at 11:58 am #230106In reply to: Edit Topic Page
wdseocompanyParticipantJust for information the theme is Divi, using their theme builder allowing me to style and format whole taxonomies a little easier (in theory haha)
For the bits of PHP – This is what I’m using to pull in the information for singular forums:
$page_id = get_queried_object_id();
$dynamic_forum_shortcode = ‘[bbp-single-forum id=' . $page_id . ']‘;
echo do_shortcode($dynamic_forum_shortcode);And for topics as follows:
$page_id = get_queried_object_id();
$dynamic_topic_shortcode = ‘[bbp-single-topic id=' . $page_id . ']‘;
echo do_shortcode($dynamic_topic_shortcode);So in theory the idea is:
1. Pull in page id as identifier
2. Form shortcode for forum/topic
3. Add these PHP snippets to the Divi template using the Code Snippets pluginThen when someone accesses the page it should call in topic/forum based on the ID of the page
I’ll take a look into this tomorrow, changing theme and disabling plugins as thankfully it isn’t live just yet. Thanks for your help so far anyway but if you can spot any flaw in the logic so far please do alert me!
June 29, 2022 at 11:26 am #230105In reply to: Edit Topic Page
Robin WModeratorok, so presuming this is in any topic, then if you fancy sharing the shortcode you are using and the php code, I might take a look at that
Outside of your php code, I’d suggest it could be a theme or plugin issue
Themes
As a test switch to a default theme such as twentytwenty, and see if this fixes.
Plugins
If that doesn’t work, also deactivate all plugins apart from bbpress and see if this fixes. if it does, re-enable one at a time to see which is causing the error.
If you cannot do this to your site (say because it is live) then use the ‘troubleshooting’ features of this plugin to let you test without affecting other users
Then come back
June 29, 2022 at 6:51 am #230092Topic: Edit Topic Page
in forum TroubleshootingwdseocompanyParticipantHi there,
Just wondering if anyone would be able to assist with an issue I’m experiencing on a site we’re working on. Unfortunately unable to share a link due to the nature of the project.
Summary: When clicking on the edit button on the front end of topics as any role it redirects to a page showing all posts, on all forums in date order.
Setup: The way this information is pulled in to the page is using the shortcodes to pull in the topic information, using PHP to get the id of the page (in turn, the topic), adding it to the shortcode and then executing it.
This seems to be working well to date aside from the editing of the topic; as the reply function is working nicely. Basically as soon as it pops in the /edit at the end of the URL it doesn’t show the right info.
Any advice would be fantastic, again I know it is difficult without a URL however any suggestions would be great.
Kind Regards,
Matt PJune 19, 2022 at 3:03 am #229916In reply to: WYSIWYG Editor Breaks When Hitting “Reply”
Robin WModeratorthanks for posting. The site needs access to replicate so cannot be reproduced without.
bbpress does not have a WYSIWYG editor by default, so what code/plugin are you using to get this? I’d suspect your theme may be doing this, and therefore may be creating the problem.
You also have an error in your theme (Use of undefined constant bbp_reply_id ), which is either code you have added to what looks like a parent theme, or an error in the theme itself.
I’d suggest that you prove this by
Themes
As a test switch to a default theme such as twentytwenty, and see if this fixes.
Plugins
If that doesn’t work, also deactivate all plugins apart from bbpress and see if this fixes. if it does, re-enable one at a time to see which is causing the error.
If you cannot do this to your site (say because it is live) then use the ‘troubleshooting’ features of this plugin to let you test without affecting other users
Then if it is theme contact the theme author as it is a paid theme
June 15, 2022 at 3:30 pm #229864In reply to: Strip embeds like youtube and image tags
John James JacobyKeymasterMost embeds can be disabled via the “Auto-embed links” setting in:
Admin > Settings > Forums
You can also permanently unhook them:
remove_action( 'bbp_init', 'bbp_reply_content_autoembed', 8 ); remove_action( 'bbp_init', 'bbp_topic_content_autoembed', 8 );
Images are a bit trickier, as you’ll need to remove
img
from the allowed-tags array:add_filter( 'bbp_kses_allowed_tags', function( $tags = array() ) { unset( $tags['img'] ); return $tags; } );
June 15, 2022 at 2:15 pm #229861In reply to: Remove visual editor only allow code editor
John James JacobyKeymasterbbPress includes a function called
bbp_make_clickable
that is used to turn regular URLs in topic and reply contents into anchors.You would need to unhook it to prevent it from happening.
remove_filter( 'bbp_get_reply_content', 'bbp_make_clickable', 40 ); remove_filter( 'bbp_get_topic_content', 'bbp_make_clickable', 40 );
June 15, 2022 at 11:35 am #229859In reply to: Shortcodes and WP 6.0
Robin WModerator🙂 not as far as I know – many thousands of plugins use shortcodes, and WP would create massive issues if they stopped them.
June 15, 2022 at 8:10 am #229857In reply to: Shortcodes and WP 6.0
Robin WModeratorSo is this one article, or many, is it written by someone with expert knowledge or does it cite some authority?
reddit is just people chatting, so without anything more substantive, I can’t say, I’ve seen nothing.
Shortcodes just execute the same code that a block would, just with a different initiation, so hard to see how anyone can say they are slow.
There’s a flat earth community on reddit as well 🙂
June 15, 2022 at 7:16 am #229853Topic: Remove visual editor only allow code editor
in forum Troubleshootingsonalsinha21ParticipantHi,
Normally bbpress changes any URL to link or gives img tag etc.
Is it possible that we don’t have anything visual and have only plain text based response?
I am asking this because people respond to support forum with all sorts of links which goes to 404 on a later date.
Having it as a code based and not actual link will mean no more 404 in future.
-
AuthorSearch Results