WordPress.org

Forums

User Profile Picture
[resolved] Need to check whether profile pic is set or not. (4 posts)

  1. pvashist75
    Member
    Posted 1 year ago #

    Hi I need to check whether the profile picture is set from this plugin or not so that i can show some default picture at profile picture place.

    I tried putting "mt_profile_image()" in a variable and check if its empty or not but its always true. is there any other way to check this.

    http://wordpress.org/plugins/metronet-profile-picture/

  2. Ronald Huereca
    Member
    Plugin Author

    Posted 1 year ago #

    That's strange. If you set the echo argument to false, it should return the thumbnail if it exists and false if it doesn't. Have you tried that?

    You can also do what is inside the mt_profile_img for checking for the profile pic.

    It's basically:

    $profile_post_id = absint( get_user_option( 'metronet_post_id', $user_id ) );

    if( !has_post_thumbnail( $profile_post_id ) ) {
    //do something
    }
  3. Ronald Huereca
    Member
    Plugin Author

    Posted 1 year ago #

    BTW, you can set the echo argument to false via this route:

    //Assume $user_id is set
    $profile_pic = mt_profile_img( $user_id, array( 'echo' => false ) );
    if ( !$profile_pic ) {
      //do stuff
    }
  4. pvashist75
    Member
    Posted 1 year ago #

    Thanks for the information. Exactly this is what i was looking for.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • User Profile Picture
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.