Support » Plugins and Hacks » Members » Compatability issues with Magic Fields 2 & Members Plugins

Compatability issues with Magic Fields 2 & Members Plugins

  • therons


    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

          // 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’) that there is an issue.
    the get_group function looks like this.
    Code from Magic Fields 2

    <?php 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",
      $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'];
          $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' );
    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 getting use to the markup here.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Justin Tadlock


    WordPress God

    Change all instances of $members in the Magic Fields code to $magic_fields_members.



    I did a search for it and there are no instance of $members in Magic Fields?
    I’ve put 3 var_dumps as fallows…

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Which outputs as…

    <strong>first vardump</strong>
    <strong>second vardump</strong>
    array(8) { ["role_manager"]=> int(1) ["content_permissions"]=> int(1) ["content_permissions_error"]=> string(85) "
    Sorry, but you do not have permission to view this content.
    " ["login_form_widget"]=> int(1) ["users_widget"]=> int(1) ["private_blog"]=> int(0) ["private_feed"]=> int(0) ["private_feed_error"]=> string(80) "
    You must be logged into the site to view this content.
    " }
    Warning: Attempt to assign property of non-object in /home/spsp/public_html/wp-content/plugins/members/includes/functions.php on line 28
    <strong>third vardump</strong>

    Now from the reading I’ve been doing on the error and the fact that the var_dump() shows an array instead of an object I’m obviously assuming that at some point it gets changed from the object you are expecting inside of members to an array?



    A Redux of the above post…
    This time using pastebin as per the request…


Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Compatability issues with Magic Fields 2 & Members Plugins’ is closed to new replies.
Skip to toolbar