You should enable WP_DEBUG mode, so that the white screen of death will give you a more useful error message.
The white screen could be caused by a typo, but it looks ok to me. Does your host have simplexml_load_string()
? If you don’t have the simple XML library, that could be why returning $setlink works, while returning $setfound causes WSOD.
I’ve re-written your code a bit so that it has isset()
checks and so that you aren’t relying on $_POST
in your editsteamlink()
function and it checks that the simplexml_load_string
function exists.
function editsteamlink( $setlink = '' ){
if( $setlink == '' || ! function_exists( 'simplexml_load_string' ) ){
return '';
}
$setlink = untrailingslashit( $setlink ) ."/?xml=1";
$setresponse = wp_remote_get($setlink);
$setbody = wp_remote_retrieve_body($setresponse);
$setxml = simplexml_load_string($setbody);
$setfound = (string)$setxml->steamID64;
return $setfound;
}
function be_save_custom_avatar_field( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) ) {
return false;
}
$steam_link = isset( $_POST['steamlink'] ) ? $_POST['steamlink'] : '';
$steam_id = editsteamlink( $steam_link );
update_usermeta( $user_id, 'steamlink', $steam_link );
update_usermeta( $user_id, 'steamid64', $steam_id );
}
Untested, so your mileage may vary! 🙂