php - How come I cannot use bp_core_fetch_avatar() in the theme after I add filter in the plugin, wordpress buddypress? -
after add_filter code below in first plugin, cannot use bp_core_fetch_avatar() in second plugin or in theme, echo out same avatar every user, why? how can fix this? get_avatar can echo out different avatar base on user except cannot recognize $gender create in plugin tell if female or male, avatar assign base on gender . trying pass parameter $gender created in plugin, why think should figure out use bp_core_fetch_avatar(), way, get_avatar can pass parameter plugin?, know get_avatar( $id, $size,$default, $alt). anyway, want know why bp_core_fetch_avatar() echo out same avatar every user after add_filter, add 'item_id'=>"$id". thanks
<?php add_filter('bp_core_fetch_avatar',array($this,'set_buddypress_avatar'), 10, 1); ?>
<?php public function set_buddypress_avatar($html_data = ''){ $html_doc = new domdocument(); $html_doc->loadhtml($html_data); $image = $html_doc->getelementsbytagname('img'); foreach($image $data) { $original_image = $data->getattribute('src'); $size = $data->getattribute('width'); $alt = $data->getattribute('alt'); if (stripos($alt, 'profile picture of ') === 0){ // if our alt attribute has "profile picture of" in beginning... $name = str_replace('profile picture of ', '', $alt); } else if (stripos($alt, 'profile photo of ') === 0){ // or profile photo of... $name = str_replace('profile photo of ', '', $alt); } else { // if there problem - assign alt name $name = $alt; } } ?>
i want know why bp_core_fetch_avatar() echo out same avatar every user after add_filter
because added filter core bp function. try removing filter after finished in class.
Comments
Post a Comment