Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 1,501 through 1,525 (of 32,481 total)
  • Author
    Search Results
  • #222993
    Robin W
    Moderator

    I tried your code but it created a fatal issue on the site..

    ok, can you post the exact code you used, and that you put this in your child theme functions file

    georgeslangeard
    Participant

    Hello Guys,

    I’ve been wandering on the forum for quite some hours and even though the question has been raised many times, there don’t seem to have a proper answer so far.

    When you enter your username / email within the lost password form, the only thing happening is that the page refreshes with an argument: https://site.com/page/?checkemail=confirm

    It’s a bit confusing for the user. Has anyone found a way to either return a success/ failure message or at least redirecting to another page?

    (I’ve tried some function.php codes, 301 redirect and bbp-style-pack.4.8.9)

    Many thanks in advance for your help,

    georges

    #222989
    georgeslangeard
    Participant

    Hello there,

    I know that this thread is quiet old but I got the same problem.

    There is no way for the user to know if the lost password request has been sent.

    I tried your code but it created a fatal issue on the site..

    Does anyone of you found a solution / alternative to this problem?

    Many thanks in advance for your help.

    georges

    #222984
    bhkh
    Participant

    Layout and functionality – Examples you can use

    In #16 the code says this:

    //filter to add description after forums titles on forum index
    function rw_singleforum_description() {
      echo '<div class="bbp-forum-content">';
      echo bbp_forum_content();
      echo '</div>';
    }
    add_action( 'bbp_template_before_single_forum' , 'rw_singleforum_description');

    But I believe it should be:

    function rw_singleforum_description() {
      echo '<div class="bbp-forum-content">';
      echo bbp_forum_content();
      echo '</div>';
    }
    add_action( 'bbp_template_before_single_forum' , 'rw_singleforum_description');

    The first code causes the html to display on the front end.

    #222980

    In reply to: Allow empty replies

    Robin W
    Moderator

    there should be an error message at the top saying

    Your reply cannot be empty.

    but the other plugin may be affecting this.

    the quickest way to correct this is to create some content if it is blank.

    This filter (untested) will deal with empty content and add a space character.

    add_filter ('bbp_new_reply_pre_content' , 'rew_allow_blank_content') ;
    
    function rew_allow_blank_content ($reply_content) {
    	if ( empty( $reply_content ) ) {
    		$reply_content = ' ' ;
    	}
    return $reply_content ;
    }

    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

    Code Snippets

    I have initially set it to change empty content to a single space character ie

    $reply_content = ' ' ;

    however later checking by WordPress may delete this, so it may need some actual text – maybe like

    $reply_content = 'this reply is has no text' ;

    #222956
    Robin W
    Moderator

    ok, I should say that I am NOT a bppress author, I am just a user who tries to help others.

    I am author of bbp private groups plugin, which would not help you directly as you want non logged in to see topics, but does mean that I spent a great deal of time locking down bbpress, and knowing where the code displays stuff.

    so for instance my code will not stop searches, access via a users profile, direct entry of urls and many more.

    so if your site needs to seriously hide replies to non logged in, then you would need to hire a very experienced dev. I am trying to retire, so desperately not trying to take on work !!

    I haven’t looked at your solution, and with a smile, will not have time to do this.

    #222955
    cosmiclove1978
    Participant

    Wow, oh wow, Robin! I don’t know what to say. The timing of it is just…wow

    I thought you had given up on me. So thanks so much for getting back to me with this solution. I’ll try it too.

    I do want to say, however, that in my desperation for a solution, I hired a “developer” on Fiverr to resolve it. Well, it ended quite disappointingly. That guy couldn’t do a single task from adding css to even bothering looking at the php function I posted here earlier. Wasted 2 days and he admitted he’s not familiar with WP. Wait what? We’re now in the Resolution Center as I’ve asked for a full refund.

    So again in desperation, just before receiving your fix, here’s what I did myself with some clunky conditional Logged in/ Logged out css tweaks + the initial php code I posted (the one with all the replies still showing but with a generic message): Post before solution | working CSS solution using initial php function and the css I laboriously came up with.

    /* adding replies message */ 
    
    body:not(.logged-in) li.bbp-body > ul > li:nth-child(2) > div.loop-item--1 > div.bbp-reply-content {
    		border: 1px solid #ffa07a;
        background: antiquewhite;
        padding: 4px!important;
    }
    /* Remove content replies */
    body:not(.logged-in) li.bbp-body > ul > li:not(:nth-child(1)):not(:nth-child(2)) > div.loop-item--1 > div.bbp-reply-content{
    		display:none;
    }
    /*Remove author replies except child 1 and 2 */
    body:not(.logged-in) li.bbp-body > ul > li:not(:nth-child(1)):not(:nth-child(2)) > div.loop-item--1 > div.bbp-reply-author{
    		display:none;
    }
    
    /*Remove header replies for all but child 1 and 2 */
    body:not(.logged-in) li.bbp-body > ul > li:not(:nth-child(1)):not(:nth-child(2)) > div.loop-item--1 > div.bbp-reply-header {
    		display:none;
    }
    /*Remove headers except child (1 & 2) */
    
    body:not(.logged-in) li.bbp-body > ul > li:not(:nth-child(1)):not(:nth-child(2)) > div.bbp-reply-header{
    		display:none;
    }
    /*Remove nested replies */
    body:not(.logged-in) li.bbp-body > ul > li:nth-child(2) > ul > li:nth-child(n+1) > div.loop-item--1 > div.bbp-reply-content{
    		display:none;
    }
    /* Remove author part of nest replies */
    body:not(.logged-in) li.bbp-body > ul > li:nth-child(2) > ul > li:nth-child(n+1) > div.loop-item--1 > div.bbp-reply-author{
    		display:none;
    }
    /*remove header of nested replies 
    
    body:not(.logged-in) #topic-67506-replies > li.bbp-body > ul > li:nth-child(2) > ul{
    		display:none;
    }*/
    
    body:not(.logged-in) li.bbp-body > ul > li > ul.bbp-threaded-replies{
    		display:none;
    }

    It’s quite ugly but did the job, to my own surprise. I was leaving my desk now, and signing off Gmail when I saw your reply. I will give a try and update you. Just a quick question, would you say then that with your fix, it’s still possible for someone to peek at the hidden replies if they know what they’re doing? It’s 2:19AM, i’m fried! So grateful for the assistance. I’ll let you know as soon as I place your solution in my child theme.

    Take care, and ttyl.
    H

    #222954
    Robin W
    Moderator

    This should do what you want

    <?php
    
    /**
     * Replies Loop - Single Reply
     *
     * @package bbPress
     * @subpackage Theme
     */
    
    // Exit if accessed directly
    defined( 'ABSPATH' ) || exit;
    
    ?>
    
    <?php 
    $reply_id = bbp_get_reply_id() ;
    // first topic reply shouldn't be hiding
    $rep_position = bbp_get_reply_position($reply_id);
     
    // if user is not logged in and not the first post topic
    if ( !is_user_logged_in() && $rep_position == 2 ) {
    	echo "<br/><strong>Replies only viewable for logged in users</strong>" ;
    bbp_get_template_part( 'form', 'user-login' );
    } 
    elseif ( !is_user_logged_in() && $rep_position > 2 ) {
    	//do nothing !!
    }
    
    //otherwsie use is logged in and/or this is reply 1 !
    else {
    
    ?>
    
    <div id="post-<?php bbp_reply_id(); ?>" class="bbp-reply-header">
    	<div class="bbp-meta">
    		<span class="bbp-reply-post-date"><?php bbp_reply_post_date(); ?></span>
    
    		<?php if ( bbp_is_single_user_replies() ) : ?>
    
    			<span class="bbp-header">
    				<?php esc_html_e( 'in reply to: ', 'bbpress' ); ?>
    				<a class="bbp-topic-permalink" href="<?php bbp_topic_permalink( bbp_get_reply_topic_id() ); ?>"><?php bbp_topic_title( bbp_get_reply_topic_id() ); ?></a>
    			</span>
    
    		<?php endif; ?>
    
    		<a href="<?php bbp_reply_url(); ?>" class="bbp-reply-permalink">#<?php bbp_reply_id(); ?></a>
    
    		<?php do_action( 'bbp_theme_before_reply_admin_links' ); ?>
    
    		<?php bbp_reply_admin_links(); ?>
    
    		<?php do_action( 'bbp_theme_after_reply_admin_links' ); ?>
    
    	</div><!-- .bbp-meta -->
    </div><!-- #post-<?php bbp_reply_id(); ?> -->
    
    <div <?php bbp_reply_class(); ?>>
    	<div class="bbp-reply-author">
    
    		<?php do_action( 'bbp_theme_before_reply_author_details' ); ?>
    
    		<?php bbp_reply_author_link( array( 'show_role' => true ) ); ?>
    
    		<?php if ( current_user_can( 'moderate', bbp_get_reply_id() ) ) : ?>
    
    			<?php do_action( 'bbp_theme_before_reply_author_admin_details' ); ?>
    
    			<div class="bbp-reply-ip"><?php bbp_author_ip( bbp_get_reply_id() ); ?></div>
    
    			<?php do_action( 'bbp_theme_after_reply_author_admin_details' ); ?>
    
    		<?php endif; ?>
    
    		<?php do_action( 'bbp_theme_after_reply_author_details' ); ?>
    
    	</div><!-- .bbp-reply-author -->
    
    	<div class="bbp-reply-content">
    
    		<?php do_action( 'bbp_theme_before_reply_content' ); ?>
    
    		<?php bbp_reply_content(); ?>
    
    		<?php do_action( 'bbp_theme_after_reply_content' ); ?>
    
    	</div><!-- .bbp-reply-content -->
    </div><!-- .reply -->
    
    <!-- end of else!!!-->
    <?php 
    }
    ?>

    BUT be aware this is only hiding replies at this point – there are many ways to see replies in bbpress.

    #222940
    majidmad
    Participant

    @maxlevel Element Pack is useless either. It is not clear how it works and its functionality is just to create and insert shortcode which you can do it by shortcodes provided by bbpress directly.
    I search a whole week and didn’t find any solution. Did you find any possible workaround to solve this issue?

    Thanks

    Robin W
    Moderator

    as

    <img src="http://www.kimberleygundogs.com/wp-content/uploads/2019/12/dog-jumping.jpg" alt="" />

    gives you

    Robin W
    Moderator

    I did give you the proper code – you need to link to the full url of an image ie a file that is an image file

    jappan
    Participant

    Could you please give me the proper code? I really appreciate it.

    Robin W
    Moderator

    ok, I’ll give it one more try, and then you are on your own!!

    your code would produce

    <img src="84396884_480x480.jpg">

    which is not a valid url, so produces nothing.

    you need a link which is a valid url to an image, so one where you see an image if you put the url into your browser

    jappan
    Participant

    Thank you as always. Mr Robin.
    I tried the code but it didn’t work.
    so i would like to know again.

    I have set up a third field for clarity.
    ↓this is my code↓

    add_action ( 'bbp_theme_before_topic_form_content', 'bbp_extra_fields');
    function bbp_extra_fields() {
       $value = get_post_meta( bbp_get_topic_id(), 'bbp_extra_field1', true);
       echo '<label for="bbp_extra_field1">URL</label><br>';
       echo "<input type='url' name='bbp_extra_field1' value='".$value."'>";
    
       $value11 = get_post_meta( bbp_get_topic_id(), 'bbp_extra_field2', true);
       echo '<label for="bbp_extra_field2">pic</label><br>';
       echo "<input type='file' name='bbp_extra_field2'  value='".$value11."'>";
    }
    
    add_action ( 'bbp_new_topic', 'bbp_save_extra_fields', 10, 1 );
    add_action ( 'bbp_edit_topic', 'bbp_save_extra_fields', 10, 1 );
    
    function bbp_save_extra_fields($topic_id=0) {
      if (isset($_POST) && $_POST['bbp_extra_field1']!='')
        update_post_meta( $topic_id, 'bbp_extra_field1', $_POST['bbp_extra_field1'] );
      if (isset($_POST) && $_POST['bbp_extra_field2']!='')
        update_post_meta( $topic_id, 'bbp_extra_field2', $_POST['bbp_extra_field2'] );
    }
    
    add_action('bbp_template_before_replies_loop', 'bbp_show_extra_fields');
    function bbp_show_extra_fields() {
      $topic_id = bbp_get_topic_id();
      $value1 = get_post_meta( $topic_id, 'bbp_extra_field1', true);
      $value2 = get_post_meta( $topic_id, 'bbp_extra_field2', true);
      $img1 = '<img src="'.$value2.'">' ;
      echo "Field 1: ".$value1."<br>";
       echo "Field 2: ".$value2."<br>";
    	echo "Field 3: ".$img1."<br>";	
    }


    Robin W
    Moderator

    you need to wrap the url into an image tag as in

    https://www.w3schools.com/tags/tag_img.asp

    so (untested so may need fixing) and image sizing but try

    add_action('bbp_template_before_replies_loop', 'bbp_show_extra_fields');
    function bbp_show_extra_fields() {
      $topic_id = bbp_get_topic_id();
      $value1 = get_post_meta( $topic_id, 'bbp_extra_field1', true);
      $value2 = get_post_meta( $topic_id, 'bbp_extra_field2', true);
      $img1 = '<img src="'.$value1.'">' ;
      echo "Field 1: ".$img1."<br>";
      echo "Field 2: ".$value2."<br>";
    }
    jappan
    Participant

    I want to add topic’s thumbnail filed to specify the image file of the thumbnail of the topic in the topic creation item.
    But i can’t.
    Even if I specify an image file, only the name of the file is output, and maybe the image itself cannot be saved.
    I added this code in “functions.php”.
    If I make a mistake, Please let me know.

    add_action ( 'bbp_theme_before_topic_form_content', 'bbp_extra_fields');
    function bbp_extra_fields() {
       $value = get_post_meta( bbp_get_topic_id(), 'bbp_extra_field1', true);
       echo '<label for="bbp_extra_field1">URL</label><br>';
       echo "<input type='url' name='bbp_extra_field1' value='".$value."'>";
    
       $value = get_post_meta( bbp_get_topic_id(), 'bbp_extra_field2', true);
       echo '<label for="bbp_extra_field1">pic</label><br>';
       echo "<input type='file' name='bbp_extra_field2' value='".$value."'>";
    }
    
    add_action ( 'bbp_new_topic', 'bbp_save_extra_fields', 10, 1 );
    add_action ( 'bbp_edit_topic', 'bbp_save_extra_fields', 10, 1 );
    
    function bbp_save_extra_fields($topic_id=0) {
      if (isset($_POST) && $_POST['bbp_extra_field1']!='')
        update_post_meta( $topic_id, 'bbp_extra_field1', $_POST['bbp_extra_field1'] );
      if (isset($_POST) && $_POST['bbp_extra_field1']!='')
        update_post_meta( $topic_id, 'bbp_extra_field1', $_POST['bbp_extra_field2'] );
    }
    
    add_action('bbp_template_before_replies_loop', 'bbp_show_extra_fields');
    function bbp_show_extra_fields() {
      $topic_id = bbp_get_topic_id();
      $value1 = get_post_meta( $topic_id, 'bbp_extra_field1', true);
      $value2 = get_post_meta( $topic_id, 'bbp_extra_field2', true);
      echo "Field 1: ".$value1."<br>";
      echo "Field 2: ".$value2."<br>";
    }

    This is the error I am facing!

    #222917
    cosmiclove1978
    Participant

    Hello Robin,

    Thanks for the tip. I checked section 3 of the documentation you suggested. I’ve found the loop-single-reply.php in my theme. I can certainly insert similar file in the child theme.

    Now, thought I get the “what” of your answer, the “How” still eludes me. I’ve been staring at that file for an hour, and I’ve got no clue as to where to place the cursor and what to write if you showed me where to place that cursor in the file.

    The code pasted above in my original post was copied and pasted as is in my Child Theme’s function.php, hoping that it would at least replace actual replies with the generic statement, which it did.

    Will you be so kind as to look at the loop-single-reply.php file below and instruct me how to change the file so that I get the intend result across the forum (for anonymous users, removing/hiding all replies except the first one + original post, and with the 1st reply showing “generic statement + Login | Register” urls)?

    <?php
    
    /**
     * Replies Loop - Single Reply
     *
     * @package bbPress
     * @subpackage Theme
     */
    
    // Exit if accessed directly
    defined( 'ABSPATH' ) || exit;
    
    ?>
    
    <div id="post-<?php bbp_reply_id(); ?>" class="bbp-reply-header">
    	<div class="bbp-meta">
    		<span class="bbp-reply-post-date"><?php bbp_reply_post_date(); ?></span>
    
    		<?php if ( bbp_is_single_user_replies() ) : ?>
    
    			<span class="bbp-header">
    				<?php esc_html_e( 'in reply to: ', 'bbpress' ); ?>
    				<a class="bbp-topic-permalink" href="<?php bbp_topic_permalink( bbp_get_reply_topic_id() ); ?>"><?php bbp_topic_title( bbp_get_reply_topic_id() ); ?></a>
    			</span>
    
    		<?php endif; ?>
    
    		<a href="<?php bbp_reply_url(); ?>" class="bbp-reply-permalink">#<?php bbp_reply_id(); ?></a>
    
    		<?php do_action( 'bbp_theme_before_reply_admin_links' ); ?>
    
    		<?php bbp_reply_admin_links(); ?>
    
    		<?php do_action( 'bbp_theme_after_reply_admin_links' ); ?>
    
    	</div><!-- .bbp-meta -->
    </div><!-- #post-<?php bbp_reply_id(); ?> -->
    
    <div <?php bbp_reply_class(); ?>>
    	<div class="bbp-reply-author">
    
    		<?php do_action( 'bbp_theme_before_reply_author_details' ); ?>
    
    		<?php bbp_reply_author_link( array( 'show_role' => true ) ); ?>
    
    		<?php if ( current_user_can( 'moderate', bbp_get_reply_id() ) ) : ?>
    
    			<?php do_action( 'bbp_theme_before_reply_author_admin_details' ); ?>
    
    			<div class="bbp-reply-ip"><?php bbp_author_ip( bbp_get_reply_id() ); ?></div>
    
    			<?php do_action( 'bbp_theme_after_reply_author_admin_details' ); ?>
    
    		<?php endif; ?>
    
    		<?php do_action( 'bbp_theme_after_reply_author_details' ); ?>
    
    	</div><!-- .bbp-reply-author -->
    
    	<div class="bbp-reply-content">
    
    		<?php do_action( 'bbp_theme_before_reply_content' ); ?>
    
    		<?php bbp_reply_content(); ?>
    
    		<?php do_action( 'bbp_theme_after_reply_content' ); ?>
    
    	</div><!-- .bbp-reply-content -->
    </div><!-- .reply -->
    

    On a separate note, have you developed any BBpress plugin having an upload function not restricted to the media library / where files are retrieved from the user’s local machines directly?

    Thanks in advance for your continued support.
    H

    #222912
    manojmohandev
    Participant

    HTTP status code received for the reference page is 404 and not 200. That will be considered bad for SEO as it is giving 404 response for page which has content to display. You can check the console also too see the status code

    #222909
    Robin W
    Moderator

    the problem is that you are changing the actual content box, so it will still display 20 boxes with author details and only blank the boxes.

    you basically need to alter the bbpress template loop-single-reply.php to achieve what you want

    see

    Step by step guide to setting up a bbPress forum – part 3

    section 3

    #222903
    cosmiclove1978
    Participant

    Dear bbPress-ers!
    Hello. I’m Herman.
    I will greatly appreciate your assistance with a couple of problems with my forum I’ve been trying to fix for a couple of days now with no solution.

    I wanted to display the message “Replies not viewable to non-members” to anonymous/not-logged-in users browsing my forum. This message replaces all actual replies with the generic one above. I was able to achieve this with the code below found on this page Dezzain website. The problem though is that this message shows up everywhere a reply is posted. So if there are 20 replies, there will be 20 generic messages.
    So my request for help #1: I would like the 1 reply ONLY to display the generic message, and the other replies hidden. Any chance you can help me with it please?
    #2, I would like to include a link to register/login in that generic reply. I am not too familiar with php. Can anyone rewrite the message below so that it also has a url portion for “Login here” | Register”?

    Thanks so very much in advance.

    bb_auth_reply_view( 
    $reply_id
    ) {
    $reply_id
    = bbp_get_reply_id( 
    $reply_id
    );
     
    // Check if password is required
    if
    ( post_password_required( 
    $reply_id
    ) )
    return
    get_the_password_form();
     
    $content
    = get_post_field( 
    'post_content'
    , 
    $reply_id
    );
     
    // first topic reply shouldn't be hiding
    $rep_position
    = bbp_get_reply_position(
    $reply_id
    );
     
    // if user is not logged in and not the first post topic
    if
    ( !is_user_logged_in() && 
    $rep_position
    > 1 ) {
    return
    "Replies only viewable for logged in users"
    ;
    } 
    else
    {
    // return normal
    return
    $content
    ;
    }
     
    }
    add_filter( 
    'bbp_get_reply_content'
    , 
    'bb_auth_reply_view'
    );
    #222898
    jappan
    Participant

    Ok! Mr.Robin
    This is my code

    <!DOCTYPE html><html lang="ja"><head><div class="login-box">
    <?php if ( is_user_logged_in() ) : ?>
     <a href="<?php echo bp_loggedin_user_domain(); ?>
    "><?php bp_loggedin_user_avatar( 'type=thumb&width=40&height=40' ); ?></a><?php global $user_identity; echo $user_identity; ?>
    <a href="<?php echo wp_logout_url( bp_get_root_domain() ) ?>">logout</a>
    <?php else : ?><a href="http://localhost/wp01/wp-login-php">login</a><?php endif; ?></div></head>
    Robin W
    Moderator

    just tested it on my site, and it seems to work.

    where did you put the code?

    hondendroom
    Participant

    Thanks Robin,
    I put it in the code snippet but unfortunately …. it didn’t work.
    I still go to the last page after a reply or a post.

    Robin W
    Moderator

    untested but try this

    add_filter ('bbp_new_reply_redirect_to', 'rew_redirect_to_topic', 10 , 3) ;
    
    function rew_redirect_to_topic ($reply_url, $redirect_to, $reply_id ) {
    	$topic_id = bbp_get_reply_topic_id ($reply_id) ;
    	$redirect_url = bbp_get_topic_permalink( $topic_id, $redirect_to );
    return $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

    Code Snippets

    #222829
    hellotoyou
    Participant

    Hi i was going to use bbpress on my site https://yourwp.site
    But the layout doesn’t look good on my theme.
    There is some place with tips and/or code snippets to improve it?

Viewing 25 results - 1,501 through 1,525 (of 32,481 total)
Skip to toolbar