BuddyDev

Search

[Resolved] Issue with post_content field for BuddyBlog Pro and BP Simple Front End Post

  • Participant
    Level: Initiated
    Posts: 7
    Azra Kadrić on #53103

    Hi, I am experiencing very inconsistent behavior regarding these 2 plugins. I already tested it with all other plugins turned off, and a basic Hello Elementor theme, the issue persists. Basically the editor defauls to Text (HTML) editor for a lot of my users, and some dont even have the option to switch to visual. I tried forcing using tmce editor through code in numerous ways, but couldn’t help it.
    Screenshots below:
    https://prnt.sc/la-Ja70faCIQ user 1
    https://prnt.sc/fCgO1kpbAkhy user 2 (both subscriber role)
    https://prnt.sc/uExA4HLCEkZz my view (admin)

  • Participant
    Level: Initiated
    Posts: 7
    Azra Kadrić on #53104

    Related buddyblog form: https://prnt.sc/6ulNcmHrsRjc

  • Participant
    Level: Initiated
    Posts: 7
    Azra Kadrić on #53105

    Additional info: for some very odd reason, It works on Chrome for some users when i add this to my functions.php, although rich_editing user meta is already TRUE for all users.

    function reset_editor_preference() {
        $user_id = get_current_user_id();
        update_user_meta($user_id, 'rich_editing', 'true');
    }
    add_action('init', 'reset_editor_preference');
  • Keymaster
    (BuddyDev Team)
    Posts: 24501
    Brajesh Singh on #53106

    Hi Azra,
    Thank you for your post.

    1. You do not need simple front end post plugin with BuddyBlog pro.

    2. It seems the BuddyBlog pro setting is correct. If your users have issues with default, It is probably one of the other plugins or theme causing it. BuddYblog Pro uses wp_editor to delegate to WordPress for showing the rich text editor.

    My sugegstion would be to test by switching theme/activating/deactivating plugins. I do not think the preference has any effect on front end.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 7
    Azra Kadrić on #53108

    Hi, thank you for your reply. I just tried the approach of turning off all other plugins and changing theme, again. It didn’t help unfortunately. Is there anything more I can try?

  • Participant
    Level: Initiated
    Posts: 7
    Azra Kadrić on #53109

    The best solution for me would be to completely turn off the HTML editor option, and only allow visual editor.

  • Participant
    Level: Initiated
    Posts: 7
    Azra Kadrić on #53112

    Hi, I ended up using this code for my problem. It appears to be working. I’ll leave this here for future people who may have the same problems.

    function disable_html_editor_on_frontend() {
        if (!is_admin()) {
            add_filter('user_can_richedit', '__return_true'); // Force enable rich editing
    	add_action('wp_footer', 'remove_html_editor_button', 20);
    
        }
    }
    add_action('wp_enqueue_scripts', 'disable_html_editor_on_frontend');
    
    function remove_html_editor_button() {
     ?>
        <script>
            document.addEventListener('DOMContentLoaded', function() {
                // Hide the "Tekst" (HTML) editor button
                var htmlEditorButton = document.getElementById('bbl_post_content-html');
                if (htmlEditorButton) {
                    htmlEditorButton.style.display = 'none';
                }
    
                // Ensure the Visual editor is active
                var visualEditorButton = document.getElementById('bbl_post_content-tmce');
                if (visualEditorButton && !visualEditorButton.classList.contains('active')) {
                    visualEditorButton.click();
                }
    
                // Prevent any click event on the HTML editor button if it's still accessible somehow
                if (htmlEditorButton) {
                    htmlEditorButton.addEventListener('click', function(e) {
                        e.preventDefault(); // Prevent switching to HTML mode
                    });
                }
            });
        </script>
        <?php
    }
  • Keymaster
    (BuddyDev Team)
    Posts: 24501
    Brajesh Singh on #53117

    Hi Azra,
    Thank you for sharing the code.

    This is hackish way of resolving it without identifying the actual issue. I do understand we all have time constraints, so I am happy that it got the editor working for you.

    PS:- The quick tags can be disabled by filtering on wp_editor_settings and that would leave the visual mode only.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 7
    Azra Kadrić on #53193

    Hi Brajesh,

    Thank you for your suggestion! I applied the wp_editor_settings filter, and it worked perfectly, providing an even cleaner solution. I appreciate your help in pointing me in the right direction.

    Best regards,

    Azra

  • Participant
    Level: Initiated
    Posts: 7
    Azra Kadrić on #53194

    Oh wow, I was going to make another support ticket regarding my editor not working (unclickable content area) in Mozilla browser. Behold, it started working when I applied your solution!

You must be logged in to reply to this topic.

This topic is: resolved