BuddyDev

Search

PHP Fatal error: Uncaught TypeError

  • Participant
    Farmasista GmbH on #52768

    Hello,
    one of our common customer had an issue with your BuddyPress Profile Data Control Plugin:
    PHP Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, string given in /bp-profile-data-control/src/core/bp-profile-data-control-functions.php:337
    After some research I found the root of the problem.
    In your bp_profile_data_control_get_editable_roles function you are using get_meta under the hood which can return a string not only an array.

    Hereby my fix for the problem:

    
    
    function bp_profile_data_control_get_editable_roles( $field_id, $context = 'field' ) {
    	$roles = bp_xprofile_get_meta( $field_id, $context, '_bppc_editable_roles', true );
    
    	if ( empty( $roles ) ) {
    		$roles = array( 'self' );
    	}
    	if (is_array($roles)) {
    		return $roles;
    	}
    
    	return array($roles);
    }
    
  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #52770

    Hi,
    Thank you for reporting the issue.

    It is a very unlikely scenario as we control the stored values.
    I have updated the plugin. Please upgrade to 1.2.2 and it should work fine.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved