Theme my login does not allow embedding.
As I wrote at the beginning of the post, I would like to customize the bbpress login page.
Can you help me run that PHP code with Code Snippets?
Thank you very much!
<?php
if ( ! is_user_logged_in() ) { // Display WordPress login form:
$args = array(
'redirect' => admin_url(),
'form_id' => 'loginform-custom',
'label_username' => __( 'Username custom text' ),
'label_password' => __( 'Password custom text' ),
'label_remember' => __( 'Remember Me custom text' ),
'label_log_in' => __( 'Log In custom text' ),
'remember' => true
);
wp_login_form( $args );
} else { // If logged in:
wp_loginout( home_url() ); // Display "Log Out" link.
echo " | ";
wp_register('', ''); // Display "Site Admin" link.
}
?>
I entered that code with the Code Snippets Plugin but it didn’t work 🙁
that is a page full of code – so what did you put in?
Hi Robin,
thanks for your reply.
I entered that code with the Code Snippets Plugin but it didn’t work. Why?
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
did you correct the error in this line
if (!empty ($topic) {
should be
if (!empty ($topic)) {
Hi Robin, thank you for the example code! I have tried it and it seems to return the same value regardless of the title, so I am unsure…
Here is the sample code that I have used the function within:
function return_content_replies() {
$title = $_POST['title'];
$topic_id = rew_find_topic_id($title);
if ( $topic_id == 'empty' ) {
// create the topic here
} else {
$args = array(
'post_parent' => $topic_id, // ID of the topic
'order' => 'ASC', // Order of the replies (ASC or DESC)
);
$replies_array = array();
if ( bbp_has_replies( $args ) ) {
while ( bbp_replies() ) {
bbp_the_reply();
$replies_array[] = array(
'id' => bbp_get_reply_id(),
'content' => bbp_get_reply_content(),
'date' => bbp_get_reply_post_date(),
);
}
}
$response = array( 'status' => 'success', 'message' => $topic_id);
}
wp_send_json($response);
}
if title is unique then
get_page_by_title()
untested but something like :
function rew_find_topic_id ($title) {
$topic = get_page_by_title($title, OBJECT, bbp_get_topic_post_type());
if (!empty ($topic) {
$topic_id = $topic->ID ;
return $topic_id ;
}
else {
return 'empty' ;
}
}
These 3 items show nothing on the user profile Forums tab. Inspector shows that div.bp-user-section is empty, and there is no “Oh bother!” message displayed on the page.
However, Replies Created DOES show replies or the “Oh bother!” message if empty.
I know Favorites were displaying when I first set up the site, but now that i’m circling back to deal with notifications and such I just noticed that it is gone. So I can’t say when/how it was broken.
I ran the forum fixes and purged cache but there was no change. I’ve tried disabling some BP/bbp related plugins but also no luck. I DO have Favorites and Engagements enabled under Settings>Forums. I’ve implemented various pieces of custom code related to BP/bbp but I don’t see how they would interfere with only those 3 items and not the replies.
Hoping someone might know offhand what could be interfering with this data being displayed, or at least a way to debug it.
I have searched these forums and for the life of me can not find exactly what I am aiming for.
Basically I run a gaming community. For the most part, everyone uses discord, and the new forum system discord currently has. However our website has been a beacon that has kept us getting back in touch with each other for over 25 year and im trying to not only keep it alive, but adding content.
Basically I have the WP Discord plugin. I want to have BBPress allow the user to add their specific game names (battle net, steam, EA, Activision IDs) to their website / forum profile. I downloaded and installed the Advanced custom field plugin via wordpress, but it doesm’t seem to work with BBpress. If I make a new page or post I can add the fields, but I am looking more in terms of the wordpress user adding them upon registering on the site, then showing in the BBpress profile.
I used to modify SMF years ago and played around a lot with different content management forum software, but am fairly new to wordpress itself, and I ABSOLUTELY LOVE how bbpress feels familiar to me. I feel like this is something super simple and easy to accomplish and im just looking in the wrong place.
On our old SMF forum, I literally had it setup in a URL format to where you would put your Steam username, but then on your profile it would be a clickable link to your steam page. It was super easy and literally required modifying the code 2 or 3 lines to fix once installing a basic plugin for SMF. I feel like this should be easier.
Can someone please point me in the right direction? Also, thank you all for what you do!
yes
$replies = bbp_has_replies( $args );
in \bbpress\includes\replies\template.php
it has these default args (some set by code above this section)
$default = array(
'post_type' => $default_post_type, // Only replies
'post_parent' => $default_post_parent, // Of this topic
'posts_per_page' => bbp_get_replies_per_page(), // This many
'paged' => bbp_get_paged(), // On this page
'orderby' => 'date', // Sorted by date
'order' => 'ASC', // Oldest to newest
'hierarchical' => $default_thread_replies, // Hierarchical replies
'ignore_sticky_posts' => true, // Stickies not supported
'update_post_term_cache' => false, // No terms to cache
but whatever you pass in $args will overwrite these
Is there a function that returns all the replies when the topicID is passed into a function?
Some example code is below for better understanding of the function I am asking about –
$args = array(
'post_parent' => $NUM, // ID of the topic
'order' => 'ASC', // Order of the replies (ASC or DESC)
);
$replies = bbp_get_replies_function( $args ); // function i would like
$response = array(
status' => 'success',
'message' => $replies,
);
Hi
I would like to customize the labels on the login page at
bbpress login, password fields and the button text.
I see some related PHP code at https://codex.wordpress.org/Customizing_the_Login_Form#Make_a_Custom_Login_Page
Could you please suggest how to add that code to my website? Thank you so much!
Thank you for the reply @robin-w 🙂
When I select PHP cron event, should I enter the code in there and delete the snippet? Because when I click PHP cron event, a code editor will open.
ok, so delete the previous code and put this code instead
function bbpress_close_old_topics() {
// Auto close old topics
$topics_query = array(
'author' => 0,
'show_stickies' => false,
'parent_forum' => 'any',
'post_status' => 'publish',
'posts_per_page' => -1
);
if ( bbp_has_topics( $topics_query ) )
while( bbp_topics() ) {
bbp_the_topic();
$topic_id = bbp_get_topic_id();
$topic_date = strtotime( get_post( $topic_id, 'post_date', true ) );
$forum_id = bbp_get_topic_forum_id($topic_id);
if ($topic_date < strtotime( '-2 hours') ) // && $forum_id == 1276 )
bbp_close_topic( $topic_id );
}
}
In other words we take out the cron scheduling functions from the code
then
Event type: PHP cron event
Hook name: bbpress_close_old_topics
arguments: none
next run: now
repeat: hourly
That should do it, you should see it as an event.
If you have a topic already set to expire, it should do so immediately as you have schgeduled to run ‘now and then every hour’ in the above.
Hi, I’m thinking of hiding some items in forum & topic page as follows:
Forum page:
1) to hide forum information
2) to hide topic viewing information
see screenshot: https://paste.pics/KS7KD
Topic page:
1) to hide topic information
2) to hide post viewing information
3) to hide topic header (author & posts)
see screenshot: https://paste.pics/KS7MF
Are there any CSS codes that can achieve that?
Hey @robin-w,
thanks for your reply.
I changed the code right away after you sent the reply.
But it still does not work and I’m note sure why.
a cron event only runs at the interval specified, so the check event runs once a day ie
wp_schedule_event(time(), 'daily', 'bbpress_daily_event');
so would only close topics older than 2 hours once a day.
suggest changing that line to
wp_schedule_event(time(), 'hourly', 'bbpress_daily_event');
so it would run every hour, so topics would be closed between 2 and 3 hours depending on when cron runs in relation to their creation.
Hello!
I used the code from @robin-w and pasted it into a code snippet but it does not seem to work. That is my code:
register_activation_hook(__FILE__, 'bbpress_topic_scheduler');
add_action('bbpress_daily_event', 'bbpress_close_old_topics');
function bbpress_topic_scheduler() {
wp_schedule_event(time(), 'daily', 'bbpress_daily_event');
}
function bbpress_close_old_topics() {
// Auto close old topics
$topics_query = array(
'author' => 0,
'show_stickies' => false,
'parent_forum' => 'any',
'post_status' => 'publish',
'posts_per_page' => -1
);
if ( bbp_has_topics( $topics_query ) )
while( bbp_topics() ) {
bbp_the_topic();
$topic_id = bbp_get_topic_id();
$topic_date = strtotime( get_post( $topic_id, 'post_date', true ) );
$forum_id = bbp_get_topic_forum_id($topic_id);
if ($topic_date < strtotime( '-2 hours') ) // && $forum_id == 1276 )
bbp_close_topic( $topic_id );
}
}
The auto close time is set to 2 hours to test it and I created a comment after 2 hours because it should happen in every forum.
Have I done anything wrong? Thanks in advance! 🙂
I’m just setting up bbPress on my site (WordPress 6.1.1, custom theme non-Block Editor/Gutenberg).
I found interior forum pages are working but the main landing page was not. I was able to work around that by setting up a regular page and using the [bbp-forum-index]
shortcode, but I see the user profile pages are still not working (and they are doing exactly what the forum index page was doing before).
Here’s an example:
https://icscalendar.com/forums-home/users/room34/
It’s possible this is a problem with my theme, but I’m not immediately sure what might be wrong (and I’d like to fix this without having to test for plugin/theme conflicts because this is my live site and I don’t have a staging environment set up… yet).
I’m guessing it may be a routing issue… I do have some code in my theme that uses the template_include
filter.
tried those, still cannot replicate.
Can you try changing the forums in forum='6,8,14'
to see if it is one of those affecting?
I have to say that I’m pretty impressed by the fact that GD bbPress Tools Pro plugin has sent today news regarding the update to the next big version (7.0) and Milan will be upgrading the topic and replies system to a completely separate table.
He says that this will increase efficiency for an obvious reason (indexing of wp_postmeta for such large amount of data in many forums is obviously one of the Achilles talon of bbPress).
But to some extent I feel that this will be like a “fork” of the bbPress project.
I’m uncertain if Milan is a regular user of these forums, but I would like to see your opinions on this movement. I’ve been using GD bbPress Tools for ages because it really complements well all my devs for bbPress on my forums (and I don’t have to be duplicating the code to perform most of the features that he has already implemented), but I’m pretty skeptical that this could be a major caveat for future releases and too much attachment to Milan (in case something happens to him, and considering that this is not open sourced).
I’m not sure either if he will be implementing this for the free version in the WordPress repo.
Furthermore, I may also ask this in his private forum, but I was looking for more opinions in this official forum.
PS: Yes, Milan is around as expected @gdragon
note tested but possibly
#bbpress-forums .bbp-parent-forum-12345 p.bbp-topic-meta .bbp-topic-started-in a {
background-color: #328C00;
}
#bbpress-forums .bbp-parent-forum-12346 p.bbp-topic-meta .bbp-topic-started-in a {
background-color: #ff4b33;
}