• Resolved qnkov

    (@qnkov)


    I’m using 2.5.0 ver of UM. And because my site is running slow with UM activated, i’m using additional code from github to fix that in function.php of my theme.

    if ( function_exists( 'UM' ) ) {
    remove_action( 'pre_get_posts', array( UM()->access(), 'exclude_posts' ), 99 );
    remove_filter( 'get_next_post_where', array( UM()->access(), 'exclude_navigation_posts' ), 99 );
    remove_filter( 'get_previous_post_where', array( UM()->access(), 'exclude_navigation_posts' ), 99 );
    remove_filter( 'widget_posts_args', array( UM()->access(), 'exclude_restricted_posts_widget' ), 99 );
    remove_filter( 'wp_count_posts', array( UM()->access(), 'custom_count_posts_handler' ), 99 );
    remove_filter( 'getarchives_where', array( UM()->access(), 'exclude_restricted_posts_archives_widget' ), 99 );
    remove_action( 'pre_get_terms', array( UM()->access(), 'exclude_hidden_terms_query' ), 99 );
    remove_action( 'pre_get_comments', array( UM()->access(), 'exclude_posts_comments' ), 99 );
    remove_filter( 'comment_feed_where', array( UM()->access(), 'exclude_posts_comments_feed' ), 99 );
    remove_filter( 'wp_count_comments', array( UM()->access(), 'custom_comments_count_handler' ), 99 );
    remove_filter( 'get_comments_number', array( UM()->access(), 'disable_comments_open_number' ), 99 );
    remove_filter( 'the_title', array( UM()->access(), 'filter_restricted_post_title' ), 10 );
    }

    But today i’ve tried the new version without that code in function.php. My site with Chrome was still a bit slow, and with Opera i couldn’t even open my site. Giving me those errors:

    https://prnt.sc/mM3h80xnkK6V

    https://prnt.sc/7TlJVG7MaXwY

    Can we expect fix on those problems? I remember UM slowing my site since 2021 year.

    • This topic was modified 1 year, 7 months ago by qnkov.
    • This topic was modified 1 year, 7 months ago by qnkov.
    • This topic was modified 1 year, 7 months ago by qnkov.
Viewing 9 replies - 16 through 24 (of 24 total)
  • @qnkov

    Try to set lower priority to the filter function.

    add_filter("um_profile_tabs", "um_072522_add_comment_count", 1000 );

    Thread Starter qnkov

    (@qnkov)

    Hi – @missveronicatv

    I remember now that i wanted in my Profile in Comments section, to be able to see number of coments there. So i’ve asked here about it and i think this code was provided by developers:

    add_filter("um_profile_tabs", "um_072522_add_comment_count", 10 );
    function um_072522_add_comment_count( $tabs ){
       
       if( isset( $tabs['comments'] ) ){ 
          $args = array(
              'user_id' => um_profile_id(),   // Use user_id.
              'count'   => true // Return only the count.
          );
          $comments_count = get_comments( $args );
          $tabs['comments']['notifier'] = $comments_count;
       }
       return $tabs;
    }

    Once i have removed it. Site is running normally now. Is there a way to fix the code properly?

    @qnkov

    You should also test if the notifier has been set before by the function

    if( isset( $tabs['comments'] ) && ! isset( $tabs['comments']['notifier'] )){

    • This reply was modified 1 year, 7 months ago by missveronica.
    Thread Starter qnkov

    (@qnkov)

    @missveronicatv

    Can you past the whole code properly edited, so i wont get that problem anymore. Thanks.

    @qnkov

    This code snippet with some more changes is working OK at my site now.

    add_filter( "um_user_profile_tabs", "um_072522_add_comment_count", 1000 );
    
    function um_072522_add_comment_count( $tabs ) {
    
        if( isset( $tabs['comments'] ) && ! isset( $tabs['comments']['notifier'] ) ){ 
            $args = array(
                        'user_id' => um_profile_id(),   // Use user_id.
                        'count'   => true               // Return only the count.
                    );
    
            $comments_count = get_comments( $args );
    
            $tabs['comments']['notifier'] = $comments_count;
        }
    
        return $tabs;
    }

    Changes:
    1. Another filter hook
    2. Filter priority 1000
    3. Test if notifier being set already

    Thread Starter qnkov

    (@qnkov)

    @missveronicatv

    Thanks for your help. I’ve added the code to my functions.php, so far, no debug log and other logs shows up. And things looks to be running fine. I will test more. Bravo!

    @qnkov

    I have posted a new thread about updating the UM Documentation

    https://www.ads-software.com/support/topic/um-documentation-2/

    • This reply was modified 1 year, 7 months ago by missveronica.
    Plugin Support andrewshu

    (@andrewshu)

    Hello @qnkov

    Did you solve this problem? Can I close this topic?

    Thank you.

    Thread Starter qnkov

    (@qnkov)

    Yes, things are working fine now. Thanks to @missveronicatv

Viewing 9 replies - 16 through 24 (of 24 total)
  • The topic ‘Errors and slow site?’ is closed to new replies.