BuddyDev

Search

Default cover photo by role?

  • Participant
    Level: Enlightened
    Posts: 43
    la on #52265

    Hi,
    I want to set cover photos based on roles. I use Publish Press Capabilities for role management.
    I see your post here
    https://buddydev.com/custom-default-buddypress-user-profile-cover-photo-based-wordpress-roles/
    I can’t tell how old that post is.
    Would it work with PP Capabilities? You mention capabilities but I don’t know if it’s Publish Press version.
    Also, do you have a plugin to accomplish the same? That would be awsome 🙂
    Thanks

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #52269

    Hello La,

    Thank you for posting. In the backend Capabilities > Capabilities screen on checkbox hover you can see the capability name and Using these capabilities, you can try it.

    Instead of this

    
    bp_before_xprofile_cover_image_settings_parse_args
    

    use this

    
    bp_before_members_cover_image_settings_parse_args
    

    If still facing issues you can share the capabilities with me and I will share the code. Please let me know

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #52270

    Hello La,

    See if the following can help you.

    
    /**
     * Set different default background images based on user roles
     *
     * @param array $settings
     *
     * @return array
     */
    function buddydev_set_custom_default_profile_cover( $settings = array() ) {
    	$displayed_user_id = bp_displayed_user_id();
    
    	if ( user_can( $displayed_user_id, 'list_users' ) ) {
    		// Users with administrator role.
    		$settings['default_cover'] = 'http://example.com/cover-admin.jpg';
    	} elseif ( user_can( $displayed_user_id, 'moderate_comments' ) ) { //editor
    		// Users with editor role.
    		$settings['default_cover'] = 'http://example.com/cover-editor.jpg';
    	} elseif ( user_can( $displayed_user_id, 'edit_published_posts' ) ) { //author
    		// Users with author role.
    		$settings['default_cover'] = 'http://example.com/cover-author.jpg';
    	} elseif ( user_can( $displayed_user_id, 'edit_posts' ) ) {
    		// Users with contributor role.
    		$settings['default_cover'] = 'http://example.com/cover-contributor.jpg';
    	} else {
    		// Users with subscriber role.
    		$settings['default_cover'] = 'http://example.com/cover.jpg';
    	}
    
    	return $settings;
    }
    add_filter( 'bp_before_members_cover_image_settings_parse_args', 'buddydev_set_custom_default_profile_cover', 40 );
    
    

    Regards
    Ravi

  • Participant
    Level: Enlightened
    Posts: 43
    la on #52275

    Thank you so much! I have since decided to give Youzify a try. After reading many posts about it in your forums, it looks like there are many compatibility issues. Not your fault, I know. Will the code you so generously provided here for default cover photos by role work in the context of Youzify do you think? I don’t believe they offer that capability.

  • Participant
    Level: Enlightened
    Posts: 43
    la on #52286

    And do you think it will work in 12.0? I’ll give it a try…

  • Keymaster
    (BuddyDev Team)
    Posts: 24599
    Brajesh Singh on #52291

    Hi,
    Thank you for the reply.

    @ravisharma
    will be assisting you in the day.

    I don’t think the code will work and we do not use Youzify. We will not be able to assist if you use Youzify. We can definately assit if you use the default BuddyPress.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 43
    la on #52293

    Actually I just tested it and it works great, no problems.
    I also asked Youzify support and they said it works fine with theirs. That’s great, yours gives some wonderful additions – thank you! I love it!

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #52311

    Hello La,

    Thank you for the acknowledgement. I am glad that I could help.

    Regards
    Ravi

The topic ‘Default cover photo by role?’ is closed to new replies.

This topic is: not resolved