magic-fields-team/Magic-Fields-2 — Issue #76: Compatability issues with Members plugin.
Author: squiwrl
Created: 2011-10-25 16:19:55+00:00
State: open

Hey Guy's
I was wondering if any of you knew if membership is compatible with Magic Fields 2 [http://wordpress.org/extend/plugins/magic-fields-2/]?
I currently am using "members" [http://wordpress.org/extend/plugins/members/] as my membership and role manager.
When using them together I'm getting one hell of a confusing error:
```Warning: Attempt to assign property of non-object in /home/spsp/public_html/wp-content/plugins/members/includes/functions.php on line 22```
that shows up any time I call
Code from Magic Fields 2
```$members = get_group('exercise_instructions');```
Here's the code for context:
Code from Magic Fields 2

```";
echo $member['exercise_instructions'][1]."
";
echo $member['exercise_instructions_exercise_reps'][1]."
";
echo $member['exercise_instructions_exercise_instruction'][1]."
";
echo "
";
}
?>

'

Pages:
```
Now the strange part is that if i move the_content up it displays without error. It's only after the
get_group('exercise_instructions') that there is an issue.
the get_group function looks like this.
Code from Magic Fields 2

```ID; }

$sql = sprintf(
"SELECT m.field_name, c.type, w.meta_value, m.group_count, m.field_count, c.options ".
"FROM %s m " .
"JOIN %s c ON m.field_name = c.name " .
"JOIN %s g ON c.custom_group_id = g.id " .
"JOIN %s w ON w.meta_id = m.meta_id " .
"WHERE m.post_id = %d AND g.name = '%s' AND w.meta_value <> '' ".
"ORDER BY m.group_count,c.display_order, m.field_count ASC",
MF_TABLE_POST_META,
MF_TABLE_CUSTOM_FIELDS,
MF_TABLE_CUSTOM_GROUPS,
$wpdb->postmeta,
$post_id,
$group_name
);

$fields = $wpdb->get_results($sql,ARRAY_A);

$result = array();
foreach($fields as $field){
$type = $field['type'];
$options = $field['options'];
$value = $field['meta_value'];
$group_index = $field['group_count'];
$field_index = $field['field_count'];
$field_name = $field['field_name'];

if(is_serialized($value)){
$value= unserialize( $value );
}

$result[$group_index][$field_name][$field_index] = _processed_value($value, $type, $options,1);
}
return $result;
}
?>
```
The error...
`Warning: Attempt to assign property of non-object in /home/spsp/public_html/wp-content/plugins/members/includes/functions.php on line 22`
is coming from:
```$members->settings = get_option( 'members_settings' );```
in...
Code from Members Plugin
```
/**
* Gets a setting from from the plugin settings in the database.
*
* @since 0.2.0
*/
function members_get_setting( $option = '' ) {
global $members;

if ( !$option )
return false;

if ( !isset( $members->settings ) )

$members->settings = get_option( 'members_settings' );

if ( !is_array( $members->settings ) || empty( $members->settings[$option] ) )
return false;

return $members->settings[$option];
}
```
Sorry for the messy code presentation ... I'm having one hell of a time with the GFM markup.