Search Results for 'code'
-
AuthorSearch Results
-
April 18, 2020 at 12:24 pm #210289
In reply to: Notify user when a reply goes into moderation
Robin W
Moderator@ajtruckle Most of the code I did is probably redundant as I think digital arms moderation tools does it
But the code for Clive immediately above notifies the user that their reply is in moderation.
so
1. create a WordPress page with a permalink of ‘/moderation/’
2. put whatever message you want in there eg ‘your reply is being held in moderation’
3. if you want you can also put the shortcode [mod-return] in the page as well which will post a return link to the topic
4. add the code above to functions file or code snippets
5. when a user (logged in or anonymous if you allow that) posts a reply that goes into moderation, they are directed to your moderation page, so get certainty that their post is being held in moderation, with a link back to their topic if you’ve added the shortcodeApril 18, 2020 at 12:16 pm #210288In reply to: Notify user when a reply goes into moderation
Robin W
Moderator@clivesmith try this and you can add
[mod-return]shortcode to your moderation page that gives a return to topic link//add message if reply help in moderation add_filter ('bbp_new_reply_redirect_to' , 'rew_pending_check', 30 , 3) ; function rew_pending_check ($reply_url, $redirect_to, $reply_id) { $status = get_post_status ($reply_id) ; $topic_id = bbp_get_reply_topic_id( $reply_id ); if ($status == 'pending' ) { $reply_url = '/moderation/?moderation_pending='.$topic_id ; } return $reply_url ; } add_shortcode ('mod-return' , 'mod_return' ) ; function mod_return () { if (!empty($_REQUEST['moderation_pending'] )) { $topic_url = get_permalink( $_REQUEST['moderation_pending'] ); echo '<div class="mod-return"><a href= "'.$topic_url,'">Return to topic</a></div>'; } }April 18, 2020 at 10:16 am #210282In reply to: Notify user when a reply goes into moderation
Robin W
Moderatorok, let’s try upping the priority as that plugin updates the url, so change
add_filter ('bbp_new_reply_redirect_to' , 'rew_pending_check', 10 , 3) ;to
add_filter ('bbp_new_reply_redirect_to' , 'rew_pending_check', 30 , 3) ;April 18, 2020 at 9:22 am #210274In reply to: Notify user when a reply goes into moderation
Robin W
Moderator@clivesmith just tried an anonymous post using
//add message if reply help in moderation add_filter ('bbp_new_reply_redirect_to' , 'rew_pending_check', 10 , 3) ; function rew_pending_check ($reply_url, $redirect_to, $reply_id) { $status = get_post_status ($reply_id) ; if ($status == 'pending' ) { $reply_url = '/moderation/' ; } return $reply_url ; }and it does redirect to the moderation page – can you recheck yours please ?
April 18, 2020 at 8:08 am #210270In reply to: Notify user when a reply goes into moderation
Clivesmith
ParticipantI ran your code on my development site as a guest and it does not work it returns the same as on the live site as a guest.
As I am the only member, I only moderate guests.April 18, 2020 at 7:41 am #210265In reply to: forum title in topics page
Robin W
ModeratorPut this in your child theme’s function file – or use
add_action ('bbp_template_before_replies_loop' ,'rew_show_forum' ) ; function rew_show_forum () { $forum_id = bbp_get_topic_forum_id() ; $title = bbp_get_forum_title($forum_id) ; echo '<div class="rew-in-forum">In forum : '.$title.'</div>' ; }April 18, 2020 at 7:17 am #210262In reply to: Notify user when a reply goes into moderation
Robin W
Moderatorso are you saying my code does nothing for anonymous users ? It seems to work for logged in users.
am doing further testing later, but your feedback would be useful
April 18, 2020 at 6:53 am #210260In reply to: Notify user when a reply goes into moderation
Clivesmith
ParticipantJust realized that even without your code it comes back as /topic/adelaide-airport-adl/?moderation_pending=7608 never noticed that before
April 18, 2020 at 6:01 am #210258Robin W
Moderatoror this for full name
add_shortcode ('kiki-greet' , 'kiki_greet' ) ; function kiki_greet() { $user = wp_get_current_user() ; echo $user->first_name.' '.$user->last_name ; }April 18, 2020 at 5:58 am #210257Robin W
Moderatorah, sorry forgot that I had done that for you !
add_shortcode ('kiki-greet' , 'kiki_greet' ) ; function kiki_greet() { $user = wp_get_current_user() ; echo $user->display_name ; }and
[kiki-greet]April 18, 2020 at 5:43 am #210256Kikis
Participantadd_shortcode (‘kiki-stats’ , ‘kiki_show_stats’ ) ;
function kiki_show_stats() {
$user_count = count_users();
$users = $user_count[‘total_users’] ;
$topic_count = wp_count_posts(‘topic’);
$topics = $topic_count->publish;
$reply_count = wp_count_posts(‘reply’);
$replies = $reply_count->publish ;
$text = ‘Our ‘.$users.’ users have created ‘.$topics. ‘ topics with ‘.$replies.’ replies.’ ;
echo $text ;
}April 18, 2020 at 4:37 am #210253In reply to: Notify user when a reply goes into moderation
Clivesmith
ParticipantHi Robin,
Thank you, I would like to echo Chuckle’s comment, you are really appreciated.The code above returns me to the topic page with address as /topic/ministro-pistarini-ezeiza-international-airport-eze/?moderation_pending=7364
I added a { to the function line of the code above. I assume I did not need the original code as well.
April 18, 2020 at 4:30 am #210252In reply to: Notify user when a reply goes into moderation
Robin W
Moderatorauthors are working on stuff – they chat on slack most days – they were discussing topic counts yesterday. But they have day jobs, and writing and testing fixes when your plugin is affecting 300,000 users takes a lot of time and careful thought.
I do this totally voluntarily, so strain is entirely self inflicted 🙂 But thanks that you are thinking of me, cheers me up !
It would be good to get some feedback on the code, but I’m chugging on looking at it as a side project whilst I wait clients coming back on paid projects.
April 17, 2020 at 5:42 pm #210237In reply to: Notify user when a reply goes into moderation
Robin W
Moderatorjust had a thought
create a WordPress page with a permalink of ‘/moderation’ and in that put some text say
‘your post is being held pending moderation’
tehn put this in your child theme’s function file – or use
//add message if reply held in moderation add_filter ('bbp_new_reply_redirect_to' , 'rew_pending_check', 10 , 3) ; function rew_pending_check ($reply_url, $redirect_to, $reply_id) $status = get_post_status ($reply_id) ; if ($status == 'pending' ) { $reply_url = '/moderation/' ; } return $reply_url ; }not perfect by any means, but better than the nothing they now get
If you could test for me, I’ll see if I can improve how it works
April 17, 2020 at 5:26 pm #210236In reply to: Notify user when a reply goes into moderation
Robin W
Moderator@clivesmith – had a think about guest posters – we can’t show the post, as by definition they are not logged in, so unless you show all moderation replies to all users (which defeats the purpose of moderation 🙂 ) they won’t see the post.
bbpress doesn’t have the functionality that chuckie shows for topics above.
I’ll try and see if I can work some code as I dig further into this, but no promises 🙂
April 17, 2020 at 2:14 pm #210229In reply to: Notify user when a reply goes into moderation
Robin W
ModeratorI’ve had a play this evening with this issue.
This code is very rough and ready, but if it works as I think it does, then it shows pending REPLIES to the user who posted them and moderators and keymasters. NOT topics !!
so when a user posts a reply and it goes into moderation, they see there reply in the topic with a warning.
If you want to try it, put this in your child theme’s function file – or use
add_filter ('bbp_has_replies' , 'rew_has_replies' ) ; function rew_has_replies( $args = array() ) { /** Defaults **************************************************************/ // Other defaults $default_reply_search = bbp_sanitize_search_request( 'rs' ); $default_post_parent = ( bbp_is_single_topic() ) ? bbp_get_topic_id() : 'any'; $default_post_type = ( bbp_is_single_topic() && bbp_show_lead_topic() ) ? bbp_get_reply_post_type() : array( bbp_get_topic_post_type(), bbp_get_reply_post_type() ); $default_thread_replies = (bool) ( bbp_is_single_topic() && bbp_thread_replies() ); // Default query args $default = array( 'post_type' => $default_post_type, // Only replies 'post_parent' => $default_post_parent, // Of this topic 'posts_per_page' => bbp_get_replies_per_page(), // This many 'paged' => bbp_get_paged(), // On this page 'orderby' => 'date', // Sorted by date 'order' => 'ASC', // Oldest to newest 'hierarchical' => $default_thread_replies, // Hierarchical replies 'ignore_sticky_posts' => true, // Stickies not supported 'update_post_term_cache' => false, // No terms to cache // Conditionally prime the cache for all related posts 'update_post_family_cache' => true ); // Only add 's' arg if searching for replies // See https://bbpress.trac.wordpress.org/ticket/2607 if ( ! empty( $default_reply_search ) ) { $default['s'] = $default_reply_search; } // What are the default allowed statuses (based on user caps) if ( bbp_get_view_all( 'edit_others_replies' ) ) { // Default view=all statuses $post_statuses = array_keys( bbp_get_topic_statuses() ); // Add support for private status if ( current_user_can( 'read_private_replies' ) ) { $post_statuses[] = bbp_get_private_status_id(); } // Join post statuses together $default['post_status'] = $post_statuses; // Lean on the 'perm' query var value of 'readable' to provide statuses } else { //get public and pending (not sure if we need this or just to remove the perm status that was here ? $post_statuses = array_keys( rew_get_topic_statuses() ); } /** Setup *****************************************************************/ // Parse arguments against default values $r = bbp_parse_args( $args, $default, 'has_replies' ); // Set posts_per_page value if replies are threaded $replies_per_page = (int) $r['posts_per_page']; if ( true === $r['hierarchical'] ) { $r['posts_per_page'] = -1; } // Get bbPress $bbp = bbpress(); //now filter the query before execution // Add filter if participant $user_id = get_current_user_id() ; $role = bbp_get_user_role( $user_id ); if ($role == 'bbp_participant' || $role == 'bbp_moderator' || bbp_is_user_keymaster($user_id)) { add_filter( 'posts_where', 'rew_where' ); } // Call the query $bbp->reply_query = new WP_Query( $r ); // Remove filter if ($role == 'bbp_participant' || $role == 'bbp_moderator' || bbp_is_user_keymaster($user_id)) { remove_filter( 'posts_where', 'rew_where' ); } // Maybe prime the post author caches if ( ! empty( $r['update_post_family_cache'] ) ) { bbp_update_post_family_caches( $bbp->reply_query->posts ); } // Add pagination values to query object $bbp->reply_query->posts_per_page = (int) $replies_per_page; $bbp->reply_query->paged = (int) $r['paged']; // Never home, regardless of what parse_query says $bbp->reply_query->is_home = false; // Reset is_single if single topic if ( bbp_is_single_topic() ) { $bbp->reply_query->is_single = true; } // Only add reply to if query returned results if ( ! empty( $bbp->reply_query->found_posts ) ) { // Get reply to for each reply foreach ( $bbp->reply_query->posts as &$post ) { // Check for reply post type if ( bbp_get_reply_post_type() === $post->post_type ) { $reply_to = bbp_get_reply_to( $post->ID ); // Make sure it's a reply to a reply if ( empty( $reply_to ) || ( bbp_get_reply_topic_id( $post->ID ) === $reply_to ) ) { $reply_to = 0; } // Add reply_to to the post object so we can walk it later $post->reply_to = $reply_to; } } } // Only add pagination if query returned results if ( ! empty( $bbp->reply_query->found_posts ) && ! empty( $bbp->reply_query->posts_per_page ) ) { // Figure out total pages if ( true === $r['hierarchical'] ) { $walker = new BBP_Walker_Reply(); $total_pages = ceil( $walker->get_number_of_root_elements( $bbp->reply_query->posts ) / $bbp->reply_query->posts_per_page ); } else { // Total for pagination boundaries $total_pages = ( $bbp->reply_query->posts_per_page === $bbp->reply_query->found_posts ) ? 1 : ceil( $bbp->reply_query->found_posts / $bbp->reply_query->posts_per_page ); // Pagination settings with filter $bbp_replies_pagination = apply_filters( 'bbp_replies_pagination', array( 'base' => bbp_get_replies_pagination_base( bbp_get_topic_id() ), 'total' => $total_pages, 'current' => $bbp->reply_query->paged ) ); // Add pagination to query object $bbp->reply_query->pagination_links = bbp_paginate_links( $bbp_replies_pagination ); } } // Filter & return return apply_filters( 'rew_has_replies', $bbp->reply_query->have_posts(), $bbp->reply_query ); } function rew_get_topic_statuses( $topic_id = 0 ) { // Filter & return return (array) apply_filters( 'bbp_get_topic_statuses', array( bbp_get_public_status_id() => _x( 'Open', 'Open the topic', 'bbpress' ), ), $topic_id ); } function rew_where( $where ) { $user_id = get_current_user_id() ; global $wpdb; $posts = $wpdb->posts ; return $where . " OR ( ".$posts.".post_author = ".$user_id." AND ".$posts.".post_status = 'pending' ) "; } add_action ('bbp_theme_before_reply_content' , 'rew_pending' ); function rew_pending () { $id = bbp_get_reply_id() ; $status = get_post_status ($id) ; if ($status == 'pending' ) { echo '<i><b>This reply is pending review and can only be seen by you and the administrators</b></i>' ; } }April 17, 2020 at 6:36 am #210221In reply to: CSS styling query
Robin W
Moderatornor have I.
The function is called by core/filters.php
Line 203: add_filter( 'bbp_get_form_forum_content', 'bbp_code_trick_reverse' ); Line 206: add_filter( 'bbp_get_form_topic_content', 'bbp_code_trick_reverse' ); Line 209: add_filter( 'bbp_get_form_reply_content', 'bbp_code_trick_reverse' );so you could try
remove_filter ('bbp_get_form_forum_content', 'bbp_code_trick_reverse' );etc.
in your child theme and see what removing it doesApril 17, 2020 at 4:27 am #210218In reply to: CSS styling query
Chuckie
ParticipantThanks.
I see line 218:
$content = "\n<pre>" . $content . "</pre>\n";I suppose that could become:
$content = "\n<pre class=\"suitable-class-name\">" . $content . "</pre>\n";And that styling be moved into that class. But:
Line 133:
$content = preg_replace_callback( "!(<pre><code>|<code>)(.*?)(</code></pre>|</code>)!s", 'bbp_decode_callback', $content );I have no clue about what that code is doing.
April 17, 2020 at 2:24 am #210209In reply to: Notify user when a reply goes into moderation
cedluck
ParticipantHi there,
cancasstudio stated :
So the issue with topic going into pending, is that the topic or reply most likely has invalid formatted code. Example: User type is a URL and hit submit, it is gone. Well, no, it is pending. because https://domain.com/something is not allowed. And the app does tell the user of the error.
Is there any way we can allow people to type url in there topics/replies?
April 16, 2020 at 2:15 pm #210198In reply to: CSS styling query
Robin W
Moderatorthe only place I can find
<pre>is inincludes/common/formatting.php line 120 onwards
April 16, 2020 at 2:03 pm #210197In reply to: CSS styling query
Chuckie
ParticipantWell, the issue here is that bbPress is using a catch all for
prewhen it should be applying a class to thepreobjects that it creates. Then we wouldn’t have this issue would we? Because they would just be classes that are used by either application with their ownprecode usage.The issue is that I don’t know how or where bbPress makes use of the
pretag so that the logic can be adjusted to use a class to indicate the styling rather than that globalprecatch all.April 16, 2020 at 5:31 am #210186In reply to: add front end editor
teazmo
ParticipantNevermind. I found out, that I‘ve used the wrong shortcode in Notify, so formatting was removed by Notify
April 16, 2020 at 4:47 am #210184In reply to: CSS styling query
Chuckie
ParticipantTurns out @robin-w that my additional css is not the solution. When the user clicks “Raw” on the code block it is supposed to toggle the raw code block to be visible. And since I added that css style it has forced it to never display.
so I need another way for bbpress to do what it wants with
preblocks that does not conflict with enlighterjs.April 16, 2020 at 4:25 am #210182In reply to: Editing welcome section on home page
Robin W
Moderatorunfortunately we can’t see that link without login details (which please do not show).
You should create an ordinary WordPress page, add a block with your text, and then follow this with a shortcode block with
[bbp-forum-index]in it
April 15, 2020 at 5:26 pm #210174Topic: Any shortcode which shows user forum info
in forum InstallationAlpo
ParticipantHi everybody!
I have users from several places in our service. That means there are also several bbpress- forums in use.
I am looking for a short code which shows the forums where a user has joined. Do you have any idea? That information is available on the Buddypress profile, but it needs some clicking and our users are frustrated.
It would be nice to place the short code on sidebar so users can go directly to the forum without clicking hassle 🙂
Thanks you in advance, bbpress is dynamite 🙂
-
AuthorSearch Results