Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 1,751 through 1,775 (of 32,466 total)
  • Author
    Search Results
  • #219684
    wrip
    Participant

    @robin-w
    Thanks for your reply. I have also checked the wp_posts table.

    SELECT * FROM wp_posts WHERE post_type = "forum" OR post_type = "topic" OR post_type = "reply"

    I can see some posts with the following post types:

    • forum
    • reply
    • topic

    Are these post types part of bbPress? Are there any additional post types added by bbPress?

    Robin W
    Moderator

    if the reply is 1500 and the topic it belongs to 1000 then

    $reply_topic_id = bbp_get_reply_topic_id(1500)
    if( $reply_topic_id == 1000 ){  
            echo 'Baseball rule';     
            return;
    Julia
    Participant

    Topic insert format in specific forum can change using following code.
    For example, Forum post=1000,1300

      if( is_single(1000) ){  
            echo 'Baseball rule';     
            return;
       }elseif( is_single(1300) ) {           
            echo 'Football rule';     
            return;
        }
    

    Then how can I customize reply insert format in specific forum?
    For example, Forum post=1000,1300

    ‘reply insert format’ in content-single-topic.php .

    Robin W
    Moderator

    ok, so create a new topic form template

    find
    wp-content/plugins/bbpress/templates/default/bbpress/form-topic.php

    transfer this to your pc and edit

    change around line 199

    <?php if ( ! bbp_is_single_forum() ) : ?>

    to

    <?php if (isset($_REQUEST['bbp_forum_id'])) : ?>
    <input type="hidden" name="bbp_forum_id" value="<?php echo $_REQUEST['bbp_forum_id']; ?>" />
    <?php elseif ( ! bbp_is_single_forum() ) : ?>

    and save

    create a directory on your theme called ‘bbpress’
    ie wp-content/themes/%your-theme-name%/bbpress

    where %your-theme-name% is the name of your theme

    Then transfer the file you saved above and put in in the directory called bbpress that you created above, so you end up with
    wp-content/themes/%your-theme-name%/bbpress/form-topic.php

    bbPress will now use this template instead of the original

    then put this in your child theme functions file

    add_action ( 'bbp_template_before_single_forum', 'reww_new_topic_button' ) ;
    
    function reww_new_topic_button () {
    	$url = $url = get_home_url(); 
    	$forum_id = bbp_get_forum_id() ;
    	$url.='/topic-form/?bbp_forum_id='.$forum_id ;
    	$text = 'create new topicc' ;
    	echo '<a class="hello" href ="'.$url.'">'.$text.'</a>' ;
    }
    

    where ‘/topic-form/’ is the page you have the topic form on

    that sends a query string to the topic form page, which is then picked up by the amended template above

    #219662
    Palagrin
    Participant

    Potentially something like this, although it isn’t working as far as I can tell:

    function bbp_change_user_role_login($user) {
    
    $user_id = get_current_user_id($user);
    $current_user_role = bbp_get_user_role($user_id);
    $new_role_forum_role="bbp_moderator";
    $user_post_count = bbp_get_user_post_count( $user_id );
    
    if (($current_user_role = "bbp_participant") and ($user_post_count > 20)) {
    bbp_set_user_role( $user_id, $new_forum_role );
    }
    
    }
    add_action('wp_login', 'bbp_change_user_role_login');
    
    quix8
    Participant

    Hello, does nobody have an idea or tip for me?
    I thought this should be a common use case to link back to the back where the forums shortcode was added.

    Palagrin
    Participant

    the topic and reply forms are at the bottom of the forum and topic pages, so there is no need to visit a separate page.

    Well, yes, but it would be neat to have the option.

    I already link to the bottom of the page form via the html anchor – I’ve coded that into my theme – but I’m trying to have these forms on separate pages entirely, to make the whole thing a bit neater.

    Palagrin
    Participant

    That’s exactly what I want – I WANT it to use the template files!

    Whilst I can use the short code bbp-new-reply for example, it needs a topic ID to work. I simply don’t understand why BBP core doesn’t generate these pages programmatically – it makes absolutely no sense to me. You would think that would be basic functionality for a forum plugin!

    #219634
    vincenzon617
    Participant

    Hi, how do I access the sidebar of the topics page – where is the file that I can add my code to so it shows up on the sidebar? What I would like to do is get the current number of replies to a topic and then depending on that, execute some shortcode.

    The code I have so far is:

    	
    	<?php $replycount = bbp_get_topic_reply_count( $r['topic_id'], true ); ?>
    	
    	<?php if($replycount > 0) : ?>
    		<?php echo do_shortcode('[adace-ad id="4420"]'); ?>
    	<?php else : ?>
    		<?php if($replycount > 9) : ?>
    			<?php echo do_shortcode('[adace-ad id="4420"]'); ?>
    			<?php echo do_shortcode('[adace-ad id="4420"]'); ?>
    		<?php endif; ?>
    		<?php if($replycount > 14) : ?>
    			<?php echo do_shortcode('[adace-ad id="4420"]'); ?>
    			<?php echo do_shortcode('[adace-ad id="4420"]'); ?>
    			<?php echo do_shortcode('[adace-ad id="4420"]'); ?>
    		<?php endif; ?>
    	<?php endif; ?>

    My PHP skills aren’t great so I’m not sure if this even works but I would just like to know where abouts the place this code, so it shows up on the sidebar, and so I can test it.

    Thanks!

    Palagrin
    Participant

    But that’s using the shortcodes and creating dedicated pages in WP right?

    I want BBP to automatically generate these pages, eg. https://mywebsite.blog/forums/login

    Pages required would be:
    – login
    – register
    – password reset
    – new topic
    – new reply

    My understanding of the shortcode is that if I wanted a new topic page, I would either have to have a generic one for the whole board or I would have to create individual ones for each forum based on the forum ID.

    The solution I’m looking for is for BBP to dynamically generate them as required. Is that possible?

    It seems odd to me that BBP doesn’t already do this.

    EDIT: would something along these lines work? https://stackoverflow.com/questions/32314278/how-to-create-a-new-wordpress-page-programmatically

    Robin W
    Moderator

    ok, so your topic and reply forms will have pages with urls, so you just need to put the buttons where you want

    <input type="button" value="button name" onclick="window.open('http://www.website.com/page')" />

    #219625
    Palagrin
    Participant

    Basically, instead of having the create topic / topic reply form on the same page as the thread I want to create a button that links to a secondary page. I know this is possible with shortcodes, but is there a way of doing this without shortcodes? So that BBP auto-generates the page itself?

    Palagrin
    Participant

    I know you can use shortcodes to add forms (such as new topic, login, new reply etc) to dedicated pages, but is there a fucntion or hook I can use to simply get BBP to automatically generate a new form page?

    #219616
    Robin W
    Moderator
    #219611
    Robin W
    Moderator

    oops semi colon missing from $image = line

    <?php bbp_reply_author_link( array( 'show_role' => true ) ); ?>
    <?php 
    $image_id = get_user_meta (bbp_get_reply_author_id(),  'profile-picture' , true) ;
    $image = get_post_meta ($image_id, _wp_attached_file, true) ;
    echo '<li>herestart'.$image.'hereend</li>' ;
    ?>
    #219597

    In reply to: Edit CSS on topic page

    vincenzon617
    Participant

    Dont worry I have just found the solution myself!

    Here it is for anyone who has the same issue:

    div.bbp-forum-header, div.bbp-reply-header, div.bbp-topic-header {
        padding: 0px; 
    }
    #219596
    vincenzon617
    Participant

    Hi I would like to change this CSS code:

    .bbp-forum-header, .bbp-reply-header, .bbp-topic-header {
        clear: both;
        overflow: hidden;
        padding: 8px 10px 8px 130px;
        margin-bottom: 0;
        border-width: 1px 0 0;
        border-color: #e6e6e6;
        border-color: var(--g1-border-color);
    }

    to have its padding set to 0px.

    I have tried adding this to my style.css file in my child theme but it didn’t work:

    .bbp-forum-header, .bbp-reply-header, .bbp-topic-header {
        padding: 0px;
    }

    I am new to CSS so I’m not sure if that code above should overwrite the default styling? I assume not as it isn’t working!

    Many thanks!

    #219594
    Robin W
    Moderator

    ok, so we are making progress.

    I don’t expect this to work, just to return the next stage

    so amend that to

    <?php bbp_reply_author_link( array( 'show_role' => true ) ); ?>
    <?php 
    $image_id = get_user_meta (bbp_get_reply_author_id(),  'profile-picture' , true) ;
    $image = get_post_meta ($image_id, _wp_attached_file, true)
    echo '<li>herestart'.$image.'hereend</li>' ;
    ?>
    #219591
    Robin W
    Moderator

    ok, can you change the other one to

    <?php bbp_reply_author_link( array( 'show_role' => true ) ); ?>
    <?php 
    $avatar = get_user_meta (bbp_get_reply_author_id(),  'profile-picture' , true) ;
    echo '<li>herestart'.$avatar.'hereend</li>' ;
    ?>
    #219590
    Robin W
    Moderator

    try

    <?php 
    $neighborhood = get_user_meta (bbp_get_reply_author_id(),  'user-subdivision' , true) ;
    echo '<li>'.$neighborhood.'</li>' ;
    ?>

    come back if that doesn’t work

    #219581
    Robin W
    Moderator

    for the avatar, I need to know what is stored in the usermeta, so can you try adding this after line 44

    <?php bbp_reply_author_link( array( 'show_role' => true ) ); ?>

    to get

    <?php bbp_reply_author_link( array( 'show_role' => true ) ); ?>
    <?php 
    $avatar = get_user_meta (get_current_user_id(),  'profile-picture' , true) ;
    echo '<li>'.$avatar.'</li>' ;
    ?>

    I need to see if this produces a url or link to media item etc.

    #219580
    Robin W
    Moderator

    ok replace the

    <?php echo 'hello' ; ?>

    with

    <?php 
    $neighborhood = get_user_meta (get_current_user_id(),  'user-subdivision' , true) ;
    echo '<li>'.$neighborhood.'</li>' ;
    ?>

    and let’s see if that does that one first

    #219558
    Robin W
    Moderator

    so we need to work out which theme template is rendering the forum pages

    looking at the page you gave me, I see that the template has a div of

    <div id="content-area" class="clearfix">

    This is probably a common div to several files, but we can use it’s presence to track down the file

    so you need to look in your theme (wp-content/themes/%your-theme-name%) for likely files

    If you have notepad++ (or another text editor that will do this) you can download your theme to your computer and do a search across all the files.

    otherwise you might have files called page.php, single.php, content.php, content-page.php etc.

    in each file where you find the <div id="content-area" then add a further class, but call each one something different

    eg

    <div id="content-area myclass1" class="clearfix">
    <div id="content-area myclass2" class="clearfix">
    etc.

    then use the browser inspector and hopefully you’ll find the class repeated in there which will tell you what template it is using

    then come back

    #219557
    Robin W
    Moderator

    great, so now I need to know the names of the fields you want in the database

    so I need to construct a bit of code that looks like

    $neighborhood = get_user_meta ($user_id, ‘%what_the_field_is_called%’ , true) ;

    so I need %what_the_field_is_called% for both field 🙂

Viewing 25 results - 1,751 through 1,775 (of 32,466 total)
Skip to toolbar