Skip to:
Content
Pages
Categories
Search
Top
Bottom

first post


  • Matthias
    Participant

    @matthias70

    I can not start a new thread?
    Are new users blocked first or do you have to check my thread until its visible…
    Thanks
    Matthias

Viewing 20 replies - 1 through 20 (of 20 total)

  • Robin W
    Moderator

    @robin-w

    sorry, sometimes the spam filters are overactive.

    Add you real question below !


    Matthias
    Participant

    @matthias70

    I still can not post my question. It’s a longer question and its a link in it.
    Perhabs that’s the problem…?


    Matthias
    Participant

    @matthias70

    I found a nice code, that shows the first message in a thread for everyone.
    Answer are shown only to logged in users.

    Perfekt so far.
    BUT the code shows in every answer the same message for non logged users
    “Replies only viewable for logged in users”

    Does anyone know, how to change the code, to show only one template-notice
    “Replies only viewable for logged in users” instead?

    
    function 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' );

    Thanks
    Matthias


    Robin W
    Moderator

    @robin-w

    try your link again, as it should make it clear what you are after !


    Matthias
    Participant

    @matthias70

    That’s how it looks in my forum. There are all answer-posters visible only the text is hidden.

    Startprobleme?

    and I just want to show like the yellow template notice here

    Crop to Squares

    Thanks
    Matthias


    Robin W
    Moderator

    @robin-w

    the filter is just applying to the reply content.

    You probably want to amend a template – How php code/wordpress knowledgable are you?


    Matthias
    Participant

    @matthias70

    I thought I can do it with a filter in functions.php.
    Don’t want to setup a child theme for this.
    Is it possible to do it with just adding a additonal bbpress file to my theme?

    My php-code knowledge is just search, copy and paste 😉

    Thanks
    Matthias


    Robin W
    Moderator

    @robin-w

    I thought I can do it with a filter in functions.php.

    unfortunately not that easy if you don’t want to show the replies, as the loop-replies file has no easy filter to hook to !

    yes you can put this in your main theme, just be aware itr will get overwritten by any theme update, so keep a good note of what you did, so you can do it again if needed.

    create a directory on your theme called ‘bbpress’
    ie wp-content/%your-theme-name%/bbpress
    find
    wp-content/plugins/bbpress/templates/default/bbpress/loop-replies.php
    Make a copy of this file, and put in in the directory called bbpress that you created above, so you end up with
    wp-content/%your-theme-name%/bbpress/loop-replies.php
    bbPress will now use this template instead of the original

    so that gets the right file

    I wish I had time to write a solution for you for free, but I’m tied up in other work.

    but basically you want to look at lines

    <?php while ( bbp_replies() ) : bbp_the_reply(); ?>
    
    <?php bbp_get_template_part( 'loop', 'single-reply' ); ?>
    
    

    You want to stop it getting the template loop-single-reply if it is after pos 1, so something like

    <?php while ( bbp_replies() ) : bbp_the_reply(); ?>
    
    <?php // if user is not logged in and is the first reply
    if( !is_user_logged_in() && $rep_position =2 ) {
    echo  "Replies only viewable for logged in users";
    }
    // if user is not logged in and is after the forst reply, then don't do naything
    elseif( !is_user_logged_in() && $rep_position >2 ) {
    }
    //otherwise carry on as usual
    else bbp_get_template_part( 'loop', 'single-reply' ); ?>
    
    

    Robin W
    Moderator

    @robin-w

    small correction to above done


    Matthias
    Participant

    @matthias70

    Hm, it shows this error…
    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'bb_auth_reply_view' not found or invalid function name in ..../blog/wp-includes/plugin.php on line 213


    Robin W
    Moderator

    @robin-w

    I wish I had time to write a solution for you for free, but I’m tied up in other work.

    sorry, I’ll keep a note of this and if I get a chance look at again shortly.

    Otherwise contact me via my website

    http://www.rewweb.co.uk


    Robin W
    Moderator

    @robin-w

    maybe

    <?php while ( bbp_replies() ) : bbp_the_reply(); ?>
    // first topic reply shouldn’t be hiding
    $rep_position = bbp_get_reply_position($reply_id);

    <?php // if user is not logged in and is the first reply
    if( !is_user_logged_in() && $rep_position =2 ) {
    echo “Replies only viewable for logged in users”;
    }
    // if user is not logged in and is after the forst reply, then don’t do naything
    elseif( !is_user_logged_in() && $rep_position >2 ) {
    }
    //otherwise carry on as usual
    else bbp_get_template_part( ‘loop’, ‘single-reply’ ); ?>


    Matthias
    Participant

    @matthias70

    I think we are close, but it gives me an error in this line
    echo “Replies only viewable for logged in users”;

    Parse error: syntax error, unexpected ‘only‘ (T_STRING), expecting ‘,’ or ‘;’
    Seems like it uses the message as code?


    Robin W
    Moderator

    @robin-w

    can you post the full error and a copy of the lines above and below


    Matthias
    Participant

    @matthias70

    Hi Robin,
    The full error is this:
    Parse error: syntax error, unexpected ‘only’ (T_STRING), expecting ‘,’ or ‘;’ in …./blog/wp-content/themes/virtue_premium/bbpress/loop-replies.php on line 54

    <?php // if user is not logged in and is the first reply
    if( !is_user_logged_in() && $rep_position =2 ) {
    echo “Replies only viewable for logged in users”;
    }
    // if user is not logged in and is after the forst reply, then don’t do naything
    elseif( !is_user_logged_in() && $rep_position >2 ) {
    }
    //otherwise carry on as usual
    else bbp_get_template_part( ‘loop’, ‘single-reply’ ); ?>


    Robin W
    Moderator

    @robin-w

    try

    if( !is_user_logged_in() && $rep_position ==2 ) {


    Matthias
    Participant

    @matthias70

    That’s causing the same error!


    Robin W
    Moderator

    @robin-w

    can only suggest that there is some hidden formatting in that line, try typing it from scratch


    Matthias
    Participant

    @matthias70

    I put the whole code in the editor. But I get the same error…


    Robin W
    Moderator

    @robin-w

    sorry, but I’d need to spend time to fix this.

    If you want a paid solution, contact me via my website

    Home

Viewing 20 replies - 1 through 20 (of 20 total)
  • You must be logged in to reply to this topic.
Skip to toolbar