WordPress.org

Ready to get started?Download WordPress

Forums

Accessing function from another plugin (3 posts)

  1. s0what
    Member
    Posted 3 years ago #

    Hi!

    I know this question is more connected to object oriented coding in general, but could you please tell me, how can I access function ( sfc_get_profile_data() ) which is defined in one plugin (SimplePress forum) from another plugin (WP-PostRatings)?

    There is probably something with global variables, but I'm not sure.

  2. s0what
    Member
    Posted 3 years ago #

    this function looks like this:

    # ------------------------------------------------------------------
    # sfc_get_profile_data(userid)
    #
    # Grabs all of the profile data for specified user and
    # returns in an array
    # ------------------------------------------------------------------
    function sfc_get_profile_data($userid)
    {
    	global $wpdb;
    
    	if ($userid == 0 || $userid == '') return;
    
    	$profile=array();
    
    	# from USERS
    	$profile = $wpdb->get_row("SELECT ID, user_login, user_email, user_url, user_registered FROM ".SFUSERS." WHERE ID=".$userid, ARRAY_A);
    
    	if(empty($profile)) return;
    
    	# from USERMETA
    	$m = $wpdb->get_results("SELECT meta_key, meta_value FROM ".SFUSERMETA." WHERE user_id=".$userid, ARRAY_A);
    
    	if (empty($m)) return;
    
    	foreach ($m as $item)
    	{
    		$profile[$item['meta_key']]=$item['meta_value'];
    	}
    
    	# from SFMEMBERS
    	$m = $wpdb->get_row("SELECT * FROM ".SFMEMBERS." WHERE user_id=".$userid, ARRAY_A);
    	if (!empty($m))
    	{
    		$profile = array_merge($profile, $m);
    	}
    
    	if (isset($profile['avatar'])) $profile['avatar'] = unserialize($profile['avatar']);
    	if (isset($profile['photos'])) $profile['photos'] = unserialize($profile['photos']);
    	if (isset($profile['user_options'])) $profile['user_options'] = unserialize($profile['user_options']);
    
    	return $profile;
    }
  3. s0what
    Member
    Posted 3 years ago #

    I updated from WP 3.0 beta to WP 3.0 Final and it started working

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.