Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 1,451 through 1,475 (of 32,432 total)
  • Author
    Search Results
  • #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?

    #222823
    regnalf
    Participant

    Thanks Robin!

    And here for the record the full code i use:

    add_filter('bbp_get_breadcrumb', 'bbpress_filter_breadcrumbs', 10, 4);
    function bbpress_filter_breadcrumbs ($trail, $crumbs, $r, $args)
    {
       return '<div class="bbp-breadcrumbs">' . $trail . '</div>';
    }
    
    #222822
    Robin W
    Moderator

    you can wrap the breadcrumb in a container – there is a filter

    'bbp_get_breadcrumb'
    
    return apply_filters( 'bbp_get_breadcrumb', $trail, $crumbs, $r, $args );
    #222800
    wenghong216
    Participant

    Hi Robin, when you are mentioning the above code is use by bbpress, is it mean that it will not apply exactly to buddyboss platform plugin?

    #222797
    corrado
    Participant

    I trying to build a forum theme with divi, it is easy to create the theme for the general forum structure with the help of shortcodes
    This is my forum

    Forum

    I can use the same theme for topics as well, as in this case:
    https://www.aqazero.com/forums/forum/acquario-acquariofilia-%f0%9f%8c%8a%f0%9f%90%a0-aqa0-%f0%9f%90%9f%f0%9f%8c%bf/

    Unfortunately, however, if I open the question (post) the theme is not inherited
    https://www.aqazero.com/forums/topic/prova-topic/

    Is there a shortcodes to display the question (post) and the area to reply (reply form)?

    Thanks in advance for your answers..

    #222796
    Bedurion
    Participant

    Greetings,

    I would like to ask you what is the best way to change the bbpress role names. For example Keymaster to Support Team.

    I can’t find the way to do it, and some of the codes I found on the internet are old or I’m afraid they might break my site.

    Thanks.

    #222790
    Robin W
    Moderator

    this is the code bbpress uses

    $topics_query = array(
    
    					// What and how
    					'post_type'      => bbp_get_topic_post_type(),
    					'post_status'    => bbp_get_public_topic_statuses(),
    					'post_parent'    => $settings['parent_forum'],
    					'posts_per_page' => (int) $settings['max_shown'],
    					'meta_query'     => array( array(
    						'key'  => '_bbp_reply_count',
    						'type' => 'NUMERIC'
    					) ),
    
    					// Ordering
    					'orderby' => 'meta_value_num',
    					'order'   => 'DESC',
    
    					// Performance
    					'ignore_sticky_posts'    => true,
    					'no_found_rows'          => true,
    					'update_post_term_cache' => false,
    					'update_post_meta_cache' => false
    				);
    #222780
    specstanza
    Participant

    A little update on this too. 🙂

    The $count of favoriters is updated correctly on topic’s single page.
    But when the $count is called elsewhere, WordPress seems to take the first _bbp_favorite encounter.

    Looking at posts’ metavalues, it seems that every ‘favorite’ mention becomes an extra _bbp_favorite

    bbp_favorite

    My code doesn’t say anything about taking the highest number – maybe this would be the solution?

    $subscriptions = get_post_meta(get_the_ID(), '_bbp_favorite', true) ;
    $count = count($subscriptions) ;
    $output .= '<li><a href="' . get_permalink() . '">' . get_post_meta(get_the_ID(), 'an_extra_field', true) . '</a><br> <span> Votes :'  . get_post_meta(get_the_ID(), '_bbp_favorite', true) . '</span></li>';
              }
              $output .= '</ul>';
              wp_reset_query();
         }
         return $output;
    }
    #222773
    regnalf
    Participant

    use if(strpos($wp->request, $bbpress_index) !== false) if you also want to restrict all possible sub-urls!

Viewing 25 results - 1,451 through 1,475 (of 32,432 total)
Skip to toolbar