WordPress.org

Ready to get started?Download WordPress

Forums

Members
Compatability issues with Magic Fields 2 & Members Plugins (4 posts)

  1. therons
    Member
    Posted 2 years ago #

    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') 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",
        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 getting use to the markup here.

  2. Justin Tadlock
    Member
    Plugin Author

    Posted 2 years ago #

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

  3. therons
    Member
    Posted 2 years ago #

    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>
    NULL
    <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>
    NULL

    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?

  4. therons
    Member
    Posted 2 years ago #

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

    http://pastebin.com/bnhhifMV

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic