-
Author
-
August 22, 2014 at 00:48 #26348gm713Participant
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!
August 22, 2014 at 01:26 #26352sharmstrModeratorThere’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 solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
August 22, 2014 at 01:28 #26353sharmstrModeratorI 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 solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
August 22, 2014 at 01:34 #26355sharmstrModeratorWait. 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 solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
August 22, 2014 at 19:22 #26424AbeKeymasterI 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.August 22, 2014 at 19:32 #26428sharmstrModeratorThanks 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 solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
August 26, 2014 at 01:08 #26572gm713ParticipantThanks 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.
September 3, 2014 at 15:11 #27430AbeKeymasterHi 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 clickedHi 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.September 3, 2014 at 20:07 #27465gm713ParticipantHi 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
September 3, 2014 at 20:09 #27466gm713Participant(Non working) Code in the above comment for Login.
'<a class="bp-menu bp-login-nav kleo-show-login" href="#" '. '">Log In</a>';
September 3, 2014 at 23:14 #27484gm713ParticipantFigured 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.";
September 3, 2014 at 23:35 #27491AbeKeymasterGlad 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.September 3, 2014 at 23:38 #27492gm713ParticipantThanks for your help. Couldn’t have done it without you pointing me to source code first. I’ll mark it as resolved
September 4, 2014 at 12:26 #27526russellkhanParticipantHi gm713, could you plesae post the final code you put on function.php in child theme? Thanks
September 6, 2014 at 23:24 #27823gm713Participant@russellkhan see the attached file.
Attachments:
You must be logged in to view attached files. -
AuthorPosts
The forum ‘KLEO’ is closed to new topics and replies.