@leng7881’s code worked for me @ghoush
Log’s who knew? From further examination due to the log telling me to look I found that I have a gh_ in front of the function name when declaring it. There error is also in your updated code above. Now that I took that out it works great. Here is the code without the minor syntax error and thank you for this.
function post_published_create_topic( $ID, $post ) {
$checkduplicate = get_post_meta( $ID, 'gh_topic_created',true);
if ( empty( $checkduplicate ) ) {
$author = $post->post_author;
$name = get_the_author_meta( 'display_name', $author );
$title = $post->post_title;
$permalink = get_permalink( $ID );
$excerpt = $post->post_excerpt;
$subject = sprintf( '%s: %s', $name, $title );
$message = sprintf ('[b]%s[/b]' . "\n" . 'By %s' . "\n\n" . '[i]%s[/i]' . "\n\n" . 'View: %s' . "\n\n", $title, $name, $excerpt, $permalink );
$tags = wp_get_post_tags( $ID, array( 'fields' => 'names' ) );
$new_post = array(
'post_title' => $subject,
'post_content' => $message,
'post_parent' => 72,
'post_status' => 'publish',
'post_type' => 'topic'
);
$topic_meta = array(
'forum_id' => $new_post['post_parent']
);
$topic_id = bbp_insert_topic($new_post, $topic_meta);
if ( !empty( $topic_id ) ) {
add_post_meta($ID, 'gh_topic_created', 'true', true);
$term_taxonomy_ids = wp_set_object_terms( $topic_id, $tags, 'topic-tag' );
bbp_update_forum(array('forum_id' => 72));
}
}
}
add_action( 'publish_post', 'post_published_create_topic', 10, 2 );
As I expected, was something to do with the rewrite rules. Was a very simple fix, I simply started messing with the rewrite until it worked. This is how mine works flawlessly should anyone have the same issur and somehow stumble across this thread.
Note: This is for lighttpd. This is not an Apache or Nginx solution.
# This is mainly a fix for bbPress and its functions
url.rewrite = (
"^/(wp-admin|wp-includes|wp-content|gallery2)/(.*)" => "$0",
"^/(.*)\.(.+)$" => "$0",
"^/(.+)/?$" => "/index.php/$1"
)
}
All I did here was remove the additional forward slash within each rule.
Now my links work perfectly!
I’d like to add <link rel="prev" href=".." /> and <link rel="next" href=".." /> tags into <head> of bbpress forum page. So I need to get links for the next and previous pages of my forum. It has to be outputed in wp_head action but in that time the bbPress class is not initialized yet, so I cannot get any information from that. Can you help me?
Are you getting any error messages in your error logs? This code, unmodified, is working fine for me on 4.2.4.
I tried the theme and plugins with bbPress and I didn’t come across any issues.
I am kind of thinking it could be the index.php in your url causing the issue, but I am not really sure.
https://codex.wordpress.org/Using_Permalinks#PATHINFO:_.22Almost_Pretty.22
Since I am not 100% sure, you can try some troubleshooting to see if you can find the solution to your problem.
Troubleshooting
I got the id from the Reveal ID’s thank you for that. I am trying to get this to work on my website which currently is on a localhost so can’t send you to it. I have put the code in the functions and changed the number to 72 (my forum id), however, when I post it does not create a new topic in that forum. I have been poking around trying to get it to work and have found that some places say the publish_post is deprecated and others that say to ignore that it still works. I’m currently using wordpress version 4.2.4 and here is the code I put in my functions.
function gh_post_published_create_topic( $ID, $post ) {
$checkduplicate = get_post_meta( $ID, 'gh_topic_created',true);
if ( empty( $checkduplicate ) ) {
$author = $post->post_author;
$name = get_the_author_meta( 'display_name', $author );
$title = $post->post_title;
$permalink = get_permalink( $ID );
$excerpt = $post->post_excerpt;
$subject = sprintf( '%s: %s', $name, $title );
$message = sprintf ('[b]%s[/b]' . "\n" . 'By %s' . "\n\n" . '[i]%s[/i]' . "\n\n" . 'View: %s' . "\n\n", $title, $name, $excerpt, $permalink );
$tags = wp_get_post_tags( $ID, array( 'fields' => 'names' ) );
$new_post = array(
'post_title' => $subject,
'post_content' => $message,
'post_parent' => 72,
'post_status' => 'publish',
'post_type' => 'topic'
);
$topic_meta = array(
'forum_id' => $new_post['post_parent']
);
$topic_id = bbp_insert_topic($new_post, $topic_meta);
if ( !empty( $topic_id ) ) {
add_post_meta($ID, 'gh_topic_created', 'true', true);
$term_taxonomy_ids = wp_set_object_terms( $topic_id, $tags, 'topic-tag' );
bbp_update_forum(array('forum_id' => 72));
}
}
}
add_action( 'publish_post', 'post_published_create_topic', 10, 2 );
Any help on why this wouldn’t work for me would me much appreciated.
This is the default font-size in the bbPress stylesheet. You can overwrite the statment or install a plugin like bbp style pack which I think would take care of this for you.
#bbpress-forums {
background: 0 0;
clear: both;
margin-bottom: 20px;
overflow: hidden;
font-size: 12px;
}
You can show the topic index on your home page using this shortcode.
[bbp-topic-index]
Shortcodes
You can copy the form-topic.php into your theme/child theme into a folder called bbpress to customize the file used on your site.
Theme Compatibility
You can scroll all the way to the bottom of the file, and replace the current message
<div id="no-topic-<?php bbp_topic_id(); ?>" class="bbp-no-topic">
<div class="bbp-template-notice">
<p>You must be <a href="<?php echo site_url('/wp-login.php') ?>">logged in</a> or <a href="<?php echo site_url('/wp-login.php?action=register') ?>">registered</a> to create new topics.</p>
</div>
</div>
In BBpress each user has the ability to edit their profile users/USER/edit/
Here they can add their name, their website link and their bio by default. However, this information is never actually displayed on their profile. Why is this?
The bio should show.
https://bbpress.org/forums/profile/robkk/
As for most of the other fields, not sure really. I know though they are just going off of WordPress’s profile fields, and whatever is added to that though. I don’t know why the devs haven’t put at least website there. Maybe it is easy for spammers to take advantage of that?? First Name and Last Name could make good choices to display on the users profile too.
I will probably make a suggestion to the devs later to add more profile data to the user’s profile.
You can of course display the data in the profile by editing a template or installing a plugin.
Copy user-profile.php from the bbPress templates in the plugin to your child theme in a folder called bbpress.
Just surround the code with conditionals to only display the information when the user has inputted any information.
You have something like this for first name.
<?php if ( bbp_get_displayed_user_field( 'first_name' ) ) : ?>
<p class="bbp-user-fname"><?php bbp_displayed_user_field( 'first_name' ); ?></p>
<?php endif; ?>
YOu can also use the plugin, to display the current fields and also custom fields.
https://wordpress.org/plugins/bbp-profile-information/
Try some troubleshooting especially what is listed for plugins. Deactivate every plugin except bbPress to see if the topics can merge correctly. Activate BuddyPress right after to see if topics merge correctly in groups and normal forums. Next, activate every other plugin one at a time to see what could be causing an issue.
If you still cannot merge topics with only bbPress activated, try the other possible solutions listed like trying a default theme to see if that fixes your issue.
Troubleshooting
For others bumping into this topic, the codex article is here:
bbp_setup_current_user was called incorrectly
I just found the codex article, I will search for what plugin is causing it
I am on the latest version of WordPress, but a custom theme ( developer left it half way) so I am fixing it myself.
1) The forum page shows for post the correct numbers. Example
post tite: Voices(5), Posts (6)
but inside posts it says
This topic contains 5 replies, has 5 voices
Viewing 1 post (of 1 total)
Then it shows just the main topic, not the replies to it.
This is the code for the bbpress.php template
<?php get_header(); ?>
<div id="page-left" class="container">
<?php
the_content();
?>
</div>
<div id="page-right">
<?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>
Seems fine to me, what do you think I missed?
Read this, it is a common error usually not associated with bbPress, but other plugins.
bbp_setup_current_user was called incorrectly
Is it possible to change the multiple select form into to separate checkboxes?
I think this line (that was added in fuctions.php) should be rewritten:
$html[] = '<select class="chzn-select" multiple="multiple" name="bbp_topic_tags[]" id="bbp_topic_tags">';
I could really only find posts that were talking about bbPress v1 standalone. I did find a post that was in 2012, which I think the bbPress plugin was around then. You can study the code and see if it would work.
The page is in another language though.
Pretty permalinks en WordPress con Lighttpd
You might have removed/there isn’t a certain piece of code that renders the classes for each topic/reply.
You might be missing this in loop-single-reply.php in your custom templates that you placed in your child theme.
<?php bbp_reply_class(); ?>
Maybe this for topics too in loop-single-topic.php
<?php bbp_topic_class(); ?>
Customize this CSS from bbPress.
#bbpress-forums div.even,
#bbpress-forums ul.even {
background-color: #fff;
}
#bbpress-forums div.odd,
#bbpress-forums ul.odd {
background-color: #fbfbfb;
}
I think this custom CSS on your site is causing the issue. Try to find an alternative to what you are trying to do before.
#bbpress-forums .bbp-body div.bbp-reply-content {
clear: both;
margin: 10px;
padding: 0;
}
In this plugin though, it deletes replies by the set hours in the settings. You can edit the code to change the post_status to “publish” instead of “spam”. This might be resource intensive depending on how many replies you have currently on your forums.
@project_subdomain.
Take what I said earlier with a grain of salt, as I don’t really recommend it. Like I said, if you want hire a developer to fix any nooks and crannies that might come up doing this.
Good Morning all,
This is an issue I have had present on my bbPress forum ever since I moved away from Apache, and onto lighttpd. The difference is, I have to add the rules manually to get them to work. Anyway, here is what I currently have in my .htaccess equivalent:
# This is mainly a fix for bbPress and its functions
url.rewrite = (
"^//(wp-admin|wp-includes|wp-content|gallery2)/(.*)" => "$0",
"^//(.*)\.(.+)$" => "$0",
"^//(.+)/?$" => "/index.php/$1"
)
}
Unfortunately, whenever I try to perform an action on a post (e.g anything that utilises the “?action” URL argument), it redirects back to the post. E.g:
http://rockstarwire.net/community/thread/yrs/edit/?action=merge – Will navigate to the edit post page.
http://rockstarwire.net/community/thread/bbcodes-have-been-temporarily-disabled/?action=bbp_toggle_topic_close&topic_id=983 – Will navigate to the post again. (and won’t close the topic)
Now I am pretty sure this is going to be something to do with the URL redirects, infact, I am almost positive that will be the case.
Could anyone assist with this one?
Thanks
Sorry for the late reply, there are a couple of ways to do this.
Easiest way to do this, might be to install this plugin. And use the supplied shortcodes in the plugin.
https://wordpress.org/plugins/voter-plugin/
The supplied shortcode are one for custom post types, which you can use for bbPress’s custom post types, (topic)
[voter_plugin_top_voted type=topic num=15]
Yeah this is custom development. I suggest you hire a developer if you want something like this.
In this plugin though, it deletes replies by the set hours in the settings. You can edit the code to change the post_status to “publish” instead of “spam”. This might be resource intensive depending on how many replies you have currently on your forums.
https://wordpress.org/plugins/bbpress-auto-delete-spam-replies/