This topic has 15 replies, 5 voices, and was last updated 10 years by pittsleyb.

  • Author
  • #26348
     gm713
    Participant

    Hi,

    For a non logged in user, I’m trying to display a message in the forums (e.g. http://greencardez.net/forums/topic/introductions/ ) to let them know that they should be logged in to participate/respond in the forums.

    Basically handle it in the same way it’s handled on the post pages ( http://greencardez.net/the-new-us/ )

    How do I accomplish that? Thanks much!

    #26352
     sharmstr
    Moderator

    There’s probably several ways to achieve this. One way is to copy the /kleo/page-parts/general-before-wrap.php into your child theme and put the following just before the wrap-content div

    COPY CODE
    
    <?php if (is_bbpress() && is_user_logged_in()) echo 'You should <a href="' . wp_login_url() . '" title="Login">login</a>'; ?>
    

    This put a message at the top of every bbpress page if the user isn’t logged in.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #26353
     sharmstr
    Moderator

    I just realized what you REALLY want to do. Sorry. Give me a sec to find an answer to that.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #26355
     sharmstr
    Moderator

    Wait. Isn’t that supposed to happen with the default bbpress install? Looks like kleo turns that off?

    http://bbpress.org/forums/topic/bbpress-should-offer-to-login-in-forum/

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #26424
     Abe
    Keymaster

    I see where the problem comes from. It was hidden from css. Replace this file wp-content/themes/kleo/bbpress/css/bbpress.css with the attached until next update

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    Attachments:
    You must be logged in to view attached files.
    #26428
     sharmstr
    Moderator

    Thanks abe. I couldnt debug it myself since I dont allow access to any part of my site without being logged in.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #26572
     gm713
    Participant

    Thanks Abe. That did the trick. However, can you let me know if these 2 things are possible, and if so, how to go about it:

    1) For closed forums threads, customize the “Oh bother! No topics were found here! The forum ‘{forum name}’ is closed to new topics and replies.

    I’m housing sub-forums in a forums, so this message is misleading and may confuse website visitors. If it were up to me I’d not display it all or if I had to I’d like to change the copy to be more generic like “Please click on one of the forums above to participate in the discussion”

    2) For forums that are open, it displays a message “You must be logged in to create new topics.”

    I’d like to make “login” a hyperlink to my login modal/page.

    #27430
     Abe
    Keymaster

    Hi gm713
    1. for that you need to make your custom changes in wp-content/themes/kleo/bbpress/feedback-no-forums.php
    2. See line 234 wp-content/themes/kleo/bbpress/form-topic.php
    The modal is show when an element with class “kleo-show-login” is clicked

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #27465
     gm713
    Participant

    Hi Abe,

    Thanks for your inputs.

    Rather than making changes to the core files, I added the following code (credit: http://www.viper007bond.com/2011/07/13/changing-core-wordpress-strings/ ) in the child functions.php file to compare and replace. Figured that’ll help with future proofing.

    Having said that, I’m planning on using the same string replacement “login” string (commented) below. Can’t figure out the right syntax to get Login to fire the modal.

    // Message replacement function
    function youruniqueprefix_filter_gettext( $translated, $original, $domain ) {
    //get topic title to supress unwated string later
    //$topic_title = bp_get_the_topic_title();

    // This is an array of original strings
    // and what they should be replaced with

    $strings = array(
    ‘Oh bother! No topics were found here!’ => ‘Select one of the topics above to participate.’,
    ‘The forum ‘%s’ is closed to new topics and replies.’=>”,
    // ‘You must be logged in to create new topics.’ => ‘Please ‘ . ‘Log In‘; . ‘ to create new topics.’,
    //Add some more strings here,
    );

    // See if the current string is in the $strings array
    // If so, replace it’s translation
    if ( isset( $strings[$original] ) ) {
    // This accomplishes the same thing as __()
    // but without running it through the filter again
    $translations = &get_translations_for_domain( $domain );
    $translated = $translations->translate( $strings[$original] );
    }

    return $translated;
    }

    add_filter( ‘gettext’, ‘youruniqueprefix_filter_gettext’, 10, 3 );

    // message replacement function ends

    #27466
     gm713
    Participant

    (Non working) Code in the above comment for Login. '<a class="bp-menu bp-login-nav kleo-show-login" href="#" '. '">Log In</a>';

    #27484
     gm713
    Participant

    Figured it out. Stored it in a variable using this, and then reference it in the replacement string

    $hot_login_button = "Please " . "<a class='bp-menu bp-login-nav kleo-show-login' href='#'>Log In</a>" . " to create new topics.";

    #27491
     Abe
    Keymaster

    Glad you figured it out

    Cheers

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #27492
     gm713
    Participant

    Thanks for your help. Couldn’t have done it without you pointing me to source code first. I’ll mark it as resolved

    #27526
     russellkhan
    Participant

    Hi gm713, could you plesae post the final code you put on function.php in child theme? Thanks

    #27823
     gm713
    Participant

    @russellkhan see the attached file.

    Attachments:
    You must be logged in to view attached files.
    #34332
     pittsleyb
    Participant

    thanks just what I needed. Would I be able to use this with a button shortcode?

Viewing 16 posts - 1 through 16 (of 16 total)

The forum ‘KLEO’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?