Compatability with Magic Fields 2

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

<?php
// second way to get the fields

// get_group will return an array of all the groups and the group's fields
// the parameter for this function is the group's name
$members = get_group('exercise_instructions');
// to see how the array is formed you can use pr($members);
// the way the array is formed is
// [group index][field name][field index]
// The image fields in the array have one more level where the letter "original" and "thumb" which will show
// the original or the thumbnail image
foreach($members as $member){
echo $member['exercise_instructions_single_instruction'][1]."<br />";
echo $member['exercise_instructions'][1]."<br />";
echo $member['exercise_instructions_exercise_reps'][1]."<br />";
echo $member['exercise_instructions_exercise_instruction'][1]."<br />";
echo "<img src='".$member['exercise_instructions_demo_image'][1]['thumb']."'><br /><br />";
}
?>
<?php the_content( __( 'Continue reading ?', 'twentyten' ) ); ?>
<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong>

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’:wink: that there is an issue.

the get_group function looks like this.

Code from Magic Fields 2

function get_group( $group_name , $post_id = NULL ){
global $post,$wpdb;

if(!$post_id){ $post_id = $post->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];
}

Now I’m contemplating switching to the membership plugin based on this error. if i can’t figure out a fix for this issue.

My question is will I have a similar issue with Magic Fields & your plugin that takes care of role management and members content?