Forum Replies Created
-
In reply to: Synchronize creation Forum to a taxonomy forum
i did something else that actually work thanks for your help
In reply to: Synchronize creation Forum to a taxonomy forumsorry I did
add_action('bbp_new_forum_form', 'add_formation_field_to_forum_form');
In reply to: Synchronize creation Forum to a taxonomy forumWell it still doesn’t work, what if instead of that, I add a select on the form to create a forum, I create it also in the admin panel. how can I do that because I did
add_action('bbp_new_forum_form_after_content', 'add_formation_field_to_forum_form'); function add_formation_field_to_forum_form() { $formations = get_terms(array( 'taxonomy' => 'formation', 'hide_empty' => false, )); if (!empty($formations) && !is_wp_error($formations)) { echo '<div class="bbp-form"> <label for="forum-formation">Sélectionner une formation :</label> <select name="forum_formation" id="forum-formation">'; foreach ($formations as $formation) { echo '<option value="' . esc_attr($formation->term_id) . '">' . esc_html($formation->name) . '</option>'; } echo '</select> </div>'; } }
I want to link the forum to the taxonomy formation I think it should be more easier but in that way it doesn’t work I have linked formation to forum by doing
function link_formation_taxonomy_to_forums() { register_taxonomy_for_object_type('formation', 'forum'); } add_action('init', 'link_formation_taxonomy_to_forums');
In reply to: Synchronize creation Forum to a taxonomy forumI have the plugin BBpress that allow me to create a forum on the admin panel on wordpress, the form is basic I just have to tape a name and pusblished it. Forum > Add new > tape the name > published and my forum is create. I also have a taxonomy forum that is linked to the user for that I do use the plugin User Taxonomy & Directory.
In reply to: Synchronize creation Forum to a taxonomy forumI did
add_action('bbp_new_forum_post_extras', 'my_custom_bbp_new_forum_handler'); function my_custom_bbp_new_forum_handler( $action = '' ) { error_log('test function'); if ( 'bbp-new-forum' !== $action ) { return; } if ( ! bbp_verify_nonce_request( 'bbp-new-forum' ) ) { bbp_add_error( 'bbp_new_forum_nonce', __( '<strong>ERROR</strong>: Are you sure you wanted to do that?', 'bbpress' ) ); return; } do_action( 'bbp_new_forum_post_extras', $forum_id ); $forum_title = get_the_title($forum_id); $forum_slug = sanitize_title($forum_title); if (!term_exists($forum_title, 'forums')) { $result = wp_insert_term($forum_title, 'forums', array( 'name' => $forum_title, 'slug' => $forum_slug )); if (is_wp_error($result)) { error_log("Erreur lors de l'insertion du terme : " . $result->get_error_message()); } else { error_log("Terme de taxonomie 'forums' créé avec succès : " . print_r($result, true)); } } else { error_log("Le terme existe déjà : " . $forum_title); } $redirect_url = bbp_get_forum_permalink( $forum_id ); bbp_redirect( $redirect_url ); }
but it still doesn’t work the first error log doesn’t appear on the debug file
In reply to: PHP Deprecatedoh ok thanks