• Resolved calvinculy

    (@calvinculy)


    The latest version breaks this function that should get information on groups a user is assigned to. I’m using this to redirect users of a specific group to a specific page and it no longer works. You can see below the previous versions contained values such as group_name which is what we were operating on. The new version only shows a date/time value which is not clearly defined.

    We’ve downgraded to a previous version for now so our affected sites retain functionality.

    OLD VERSION OF pp_get_groups_for_user() OUTPUTS:
    array(4) {
    [5]=>
    object(stdClass)#5359 (13) {
    ["group_id"]=>
    string(1) "5"
    ["user_id"]=>
    string(2) "24"
    ["member_type"]=>
    string(6) "member"
    ["status"]=>
    string(6) "active"
    ["add_date_gmt"]=>
    string(19) "2024-02-28 17:28:40"
    ["date_limited"]=>
    string(1) "0"
    ["start_date_gmt"]=>
    string(19) "0000-00-00 00:00:00"
    ["end_date_gmt"]=>
    string(19) "2035-01-01 00:00:00"
    ["ID"]=>
    string(1) "5"
    ["group_name"]=>
    string(15) "[WP subscriber]"
    ["group_description"]=>
    string(42) "All users with a WordPress subscriber role"
    ["metagroup_id"]=>
    string(10) "subscriber"
    ["metagroup_type"]=>
    string(7) "wp_role"
    }
    ...
    }
    
    NEW VERSION OF pp_get_groups_for_user OUTPUTS:
    array(4) {
    [5]=>
    string(19) "2024-02-28 17:37:26"
    [13]=>
    string(19) "2024-02-28 17:37:26"
    [10]=>
    string(19) "0000-00-00 00:00:00"
    [9]=>
    string(19) "0000-00-00 00:00:00"
    }

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Riza Maulana Ardiyanto

    (@rizaardiyanto)

    Hi @calvinculy

    Thanks for reporting this.

    We have created a GitHub issue on this so our developer can fix this in the future release: https://github.com/publishpress/PublishPress-Permissions/issues/1056

    Thanks,

    Thread Starter calvinculy

    (@calvinculy)

    Thanks Riza! I appreciate the quick response.

    Plugin Author Kevin Behrens

    (@kevinb)

    @calvinculy Can you explain your use case for calling this function? What action or filter are you hooking into?

    Thread Starter calvinculy

    (@calvinculy)

    Sure! I’ve got a filter for login_redirect that upon users logging in it checks if they belong to a specific user group by getting that users groups via this function and then looping through the users groups to match based on the group_name. If it returns true then users belonging to that group are redirected to a specific management page.

    $userGroups = pp_get_groups_for_user($user->ID);
    foreach( $userGroups as $userGroup ){
    	if( $userGroup->group_name == 'Wait Time' ){
    		$waitTimeUser = true;
    	}
    }
    Plugin Author Kevin Behrens

    (@kevinb)

    @calvinculy

    The pp_get_groups_for_user() issue you reported is fixed in the current release, Permissions 4.0.20

    Thread Starter calvinculy

    (@calvinculy)

    Thanks @kevinb for the quick turn-around on fixing this!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘pp_get_groups_for_user() broken return’ is closed to new replies.