OpenSanghaFoundation / OSF

Bug/Feature requests tracking and documentation managament
https://opensanghafoundation.org
0 stars 0 forks source link

Blank user profile page for some users #15

Closed coiby closed 2 months ago

coiby commented 4 months ago

Describe the bug

Some user profile pages are blank e.g. WAT SANTIWONGSARAM but not for users like Coiby

Expected behavior All users should have their profile pages displayed.

Screenshots Screenshot_2024-03-06_20-46-55

Additional context Add any other context about the problem here.

coiby commented 4 months ago

I changed wp-content/themes/maxcoach/ultimate-member/templates/profile.php

diff --git a/maxcoach/ultimate-member/templates/profile.php.bak b/maxcoach/ultimate-member/templates/profile.php
index 5738c7b..4d263ce 100644
--- a/maxcoach/ultimate-member/templates/profile.php.bak
+++ b/maxcoach/ultimate-member/templates/profile.php
@@ -353,6 +353,7 @@ echo do_shortcode(' [xyz-ics snippet="User-Profile-Gmap"]');

 // dhammarato end code 
         }
+               echo "<pre>".print_r(debug_backtrace(2), true)."</pre>";
                do_action( 'um_profile_footer', $args ); ?>
        </div>
 </div>

and then visit a normal profile page to generate a PHP backtrace,

Array
(
    [0] => Array
        (
            [file] => /var/www/html/wp-content/plugins/ultimate-member/includes/core/class-shortcodes.php
            [line] => 327
            [function] => include
        )

    ...
    [2] => Array
        (
            [file] => /var/www/html/wp-content/plugins/ultimate-member/includes/core/class-shortcodes.php
            [line] => 838
            [function] => template_load
            [class] => um\core\Shortcodes
            [type] => ->
        )

    ...
    [29] => Array
        (
            [file] => /var/www/html/index.php
            [line] => 17
            [args] => Array
                (
                    [0] => /var/www/html/wp-blog-header.php
                )

            [function] => require
        )

)

So I narrowed down to the code in the public function load( $args ) of ShortCodes class in wp-content/plugins/ultimate-member/includes/core/class-shortcodes.php. After inserting some echo codes (in some places ob_end_flush() is also needed), I find the function returns when current_user_roles is empty for blank profile page,

            // For profiles only.
            if ( 'profile' === $mode && um_profile_id() ) {
                // Set requested user if it's not setup from permalinks (for not profile page in edit mode).
                if ( ! um_get_requested_user() ) {
                    um_set_requested_user( um_profile_id() );
                }

                if ( ! empty( $args['use_custom_settings'] ) && ! empty( $args['role'] ) ) {
                    // Option "Apply custom settings to this form". Option "Make this profile form role-specific".
                    // Show the first Profile Form with role selected, don't show profile forms below the page with other role-specific setting.
                    if ( empty( $this->profile_role ) ) {
                        $current_user_roles = UM()->roles()->get_all_user_roles( um_profile_id() );

                        if ( empty( $current_user_roles ) ) {
                            ob_get_clean();
                            return ''; // return here
                        }
coiby commented 4 months ago

So the problem is somehow majority of users lose their role thus their profile page won't be shown. https://opensanghafoundation.org/newsite/wp-admin/admin.php?page=um_roles shows only 270 users have Subscriber role, Screenshot_2024-03-06_20-39-12

OSFOSF commented 4 months ago

if we reset the users roles will the issue go away? and how did they loose their roles I avoid putting roles in the csv uploads, maybe this happens when too many csv users are added than the cloudflare time out page is shown, so uploading fewer new users in csv might help? So what do you sagest changing the roles on the user page or writing code to reset the user roles form every user?

coiby commented 4 months ago

Yes, if users have correctly assigned roles, this issue will be gone. For your reference, I checked Jan 17's database, majority of the users have been assigned to the Subscriber role, Screenshot_2024-03-06_21-07-35

coiby commented 4 months ago

and how did they loose their roles I avoid putting roles in the csv uploads, maybe this happens when too many csv users are added than the cloudflare time out page is shown, so uploading fewer new users in csv might help?

The database has general_log turned off so we currently can't know how user lost their roles. If you suspect this is caused by importing too many users, we can do a test. To help addressing future cases, I've installed Activity Log – WordPress plugin | WordPress.org to help find a clue (accessible by Activity Log in the right of the administration panel).

OSFOSF commented 2 months ago

the new user profile page fixed this