• Resolved Dan Stramer

    (@danstramer)


    Hi,
    Is there a way to add a class to posts which the user can access?
    I would like to filter images for posts who are restricted so users will know they don’t have access to them, or add a tag or badge of some sort to post which are accessible to the user. is that doable?

    Thanks
    Dan

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @danstramer

    Which posts are you referring to? Is it in the Profile’s Posts tab?

    Regards,

    Thread Starter Dan Stramer

    (@danstramer)

    Just the posts in the homepage.
    They are all set to display but have different restrictions.
    If the user does not have access to view the full post I would like to change the image a bit (greyscale filter or something similar). Or, add a badge to posts that he can access and view.
    See here:
    https://academy.dermaspark.com/

    Thanks,
    Dan

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @danstramer

    Unfortunately, UM doesn’t have the ability to add a class to your custom posts grid as It is outside of UM. This requires customization on your end.

    Regards,

    Thread Starter Dan Stramer

    (@danstramer)

    Thanks. Can UM add a class to the body with the user’s level or role?

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @danstramer

    It depends on your theme if it is supporting the body_class function.

    You can try this code snippet to add a body class:

    add_filter( 'body_class', function( $classes ) {
        $user_id = get_current_user_id();
        um_fetch_user( $user_id );
        $role = um_user("role");
    
        return array_merge( $classes, array( 'um_role-'.$role ) );
    } );

    The above code will add the current user’s role in the body class.
    e.g. um_role-administrator

    Regards,

    Thread Starter Dan Stramer

    (@danstramer)

    Thanks, yes. did exactly that. with a for each since the users can have more than one role.

    Dan

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @danstramer

    Thanks for letting us know. I’m marking this as resolved now.

    Regards,

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