Skip to:
Content
Pages
Categories
Search
Top
Bottom

Store the url of bp_loggedin_user_avatar in a php variable


  • erikreuff
    Participant

    @erikreuff

    Hi im trying to store the url of bp_loggedin_user_avatar in a php variable, but when I run the page instead of storing it, the image is displayed, even with the argument html false, what can I do?

    $mg_avatar = bp_loggedin_user_avatar( ‘type=full’,’html=false’ );

Viewing 6 replies - 1 through 6 (of 6 total)

  • Venutius
    Moderator

    @venutius

    You aren’t passing the arguments correctly, they need to be an array. Try this:

    $args = array(
    	'type'    => 'full',
    	'html'    => false
    	);
    
    $mg_avatar = bp_loggedin_user_avatar( $args );

    erikreuff
    Participant

    @erikreuff

    Thank you,the image is not showing, but now print the url in the page without an echo or print….I did a var_dump to the $mg_avatar variable and shows null….


    Venutius
    Moderator

    @venutius

    Exactly what are you looking to do?


    erikreuff
    Participant

    @erikreuff

    use the url to add it to a tag as a bacground-image inline style


    Venutius
    Moderator

    @venutius

    I always use bp_core_fetch_avatar, it’s better documented and avoids the filter, which could be the issue.

    $args = array(
            'item_id' => bp_loggedin_user_id()'
    	'type'    => 'full',
    	'html'    => false
        );
    
    $mg_avatar = bp_core_fetch_avatar( $args );

    Try that


    erikreuff
    Participant

    @erikreuff

    Thanks Venutius, you were very helpful

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Skip to toolbar