This topic has 3 replies, 3 voices, and was last updated 9 years by Andrei.

  • Author
  • #55685
     mycolombianwife
    Participant

    I got following error after upgrading to Buddypress 2.2.3.1

    Fatal error: Call to undefined function bp_core_fetch_avatar() in /homepages/15/d405161118/htdocs/mycolombianwife/wp-content/themes/sweetdate-child/functions.php on line 140

    I had to remove the functions php from my child-theme for now.

    COPY CODE
    <?php
    
    /* Restrict email messages content to non paying members */
    if ( ! function_exists('kleo_pmpro_restrict_pm_email_content')) {
        function kleo_pmpro_restrict_pm_email_content($email_content, $sender_name, $subject, $content, $message_link, $settings_link, $ud)
        {
    
            $restrict_message = false;
            $restrict_options = kleo_memberships();
            $area = 'pm';
    
            if (pmpro_getMembershipLevelForUser($ud->ID)) {
                $current_level_obj = pmpro_getMembershipLevelForUser($ud->ID);
                $current_level = $current_level_obj->ID;
    
                //if restrict my level
                if ($restrict_options[$area]['type'] == 2 && isset($restrict_options[$area]['levels']) && is_array($restrict_options[$area]['levels']) && !empty($restrict_options[$area]['levels']) && in_array($current_level, $restrict_options[$area]['levels'])) {
                    $restrict_message = true;
                }
    
            //not a member
            } else {
                if ($restrict_options[$area]['type'] == 2 && isset($restrict_options[$area]['not_member']) && $restrict_options[$area]['not_member'] == 1) {
                    $restrict_message = true;
                }
            }
    
            if ($restrict_message) {
    
                $content = 'The message is not visible for you at the moment. Only members can view and send messages. Please log in and choose one of our memberships. Thank you!';
                $email_content = sprintf(__(
                    '%1$s sent you a new message:
    
    Subject: %2$s
    
    "%3$s"
    
    To view and read your messages please log in and visit: %4$s
    
    ---------------------
    ', 'buddypress'), $sender_name, $subject, $content, $message_link);
    
                // Only show the disable notifications line if the settings component is enabled
                if (bp_is_active('settings')) {
                    $email_content .= sprintf(__('To disable these notifications, please log in and go to: %s', 'buddypress'), $settings_link);
                }
    
                return $email_content;
            }
    
            return $email_content;
    
        }
    }
    add_filter( 'messages_notification_new_message_message', 'kleo_pmpro_restrict_pm_email_content', 11, 7 );
    
    //Minify
    add_filter('bwp_minify_style_ignore', 'exclude_my_css');
    
    function exclude_my_css($excluded)
    {
        $excluded = array('app','foundation','foundation-responsive');
        return $excluded;
    }
    
    function remove_public_message_button() {
    remove_filter( 'bp_member_header_actions','bp_send_public_message_button', 20);
     
    }
    add_action( 'bp_member_header_actions', 'remove_public_message_button' );
    
    /**
     * @package WordPress
     * @subpackage Sweetdate
     * @author SeventhQueen <themesupport@seventhqueen.com>
     * @since Sweetdate 1.0
     */
    
    /**
     * Sweetdate Child Theme Functions
     * Add extra code or replace existing functions
    */
    
     add_filter( 'bp_get_message_thread_excerpt', 'kleo_custom_message_length');
    function kleo_custom_message_length($text) {
    return substr( $text,0 , 6 );
    }
    //Hide members without avatars 
    add_action( 'bp_core_delete_existing_avatar', 'log_avatar_deleted' );
    add_action( 'xprofile_avatar_uploaded', 'log_avatar_uploaded' );
    
    //on new avatar upload, record it to user meta
    function log_avatar_uploaded(){
    	update_user_meta(bp_loggedin_user_id(), 'has_avatar', 1);
    }
    
    //on delete avatar, delete it from user meta
    function log_avatar_deleted($args){
    	if($args['object']!='user')
    	return;
    	//we are sure it was user avatar delete
    	//remove the log from user meta
    	delete_user_meta(bp_loggedin_user_id(), 'has_avatar');
    }
    
    function modify_loop_and_pag($qs, $object=false) {
    	global $wpdb;
    	$include = '';
    
    	if( $object != 'members' )//hide for members only
    	return $qs;
    	
    	$subscribers = $wpdb->get_results("SELECT user_id FROM {$wpdb->usermeta } WHERE meta_key='has_avatar'" , ARRAY_N );
    	foreach($subscribers as $subscriber){
    		$include = $include . "," . $subscriber[0];
    	}
    
     $args = wp_parse_args( $qs );
     
     //check if we are listing friends?, do not apply in this case
    
     
     if( !empty( $args['include'] ) ) {
    	$args['include'] = $args['include'] . ',' . $include;
     }
     else {
    	$args['include'] = $include;
     }
     
     $qs = build_query($args);
    
     return $qs;
     
    }
    add_action( 'bp_ajax_querystring' , 'modify_loop_and_pag', 25, 2 );
    
    function current_user_has_avatar($id) {
    	global $bp;
    	if ( bp_core_fetch_avatar( array( 'item_id' => $id, 'no_grav' => true,'html'=> false ) ) != bp_core_avatar_default( 'local' ) ) {
    		return true;
    	}
    	return false;
    }
    
    // ATTENTION
    // This code should be deleted after first site load with the code
    //
    function init_avatar_meta(){
    	global $wpdb;
    	$ids=$wpdb->get_col("SELECT ID FROM $wpdb->users");//we don't need to check for meta value anyway
    	foreach( $ids as $id ){
    		if( current_user_has_avatar($id) ){
    			update_user_meta( $id, 'has_avatar', 1 );
    		} else {
    			delete_user_meta( $id, 'has_avatar' );
    		}
    	}
    }
    add_action('init', 'init_avatar_meta');  
    ?>
    #56057
     Abe
    Keymaster

    Hi, from the code I see it is in your child theme so it is custom code: themes/sweetdate-child/functions.php on line 140

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #56095
     mycolombianwife
    Participant

    All these custom code was provided by this theme support. I did´t add anything myself.

    I would just like to maintain the function that users profiles without pictures do not appear on the members page.

    #56148
     Andrei
    Moderator

    The code probably needs a few more checks in order to be safe while you update your plugins.
    A way to deal with your issue would be to remove all your custom code, update, and then put it back.

    Cheers

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Log in with your credentials

Forgot your details?