Skip to:
Content
Pages
Categories
Search
Top
Bottom

Store the url of bp_loggedin_user_avatar in a php variable

  • @erikreuff

    Participant

    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

    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

    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

    Exactly what are you looking to do?

    @erikreuff

    Participant

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

    @venutius

    Moderator

    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

    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