Group Visibility (Role Restriction) In personal settings


Home Forums Front End PM PRO Group Visibility (Role Restriction) In personal settings

This topic is: Resolved
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #17246
    Andrew Perryman
    Participant

    Hi Shamim,

    Is there a way to restrict limit the visibility of a group thats been created so that a role can’t see it in their own personal settings?

    The reason for this is that our team want to have a group setup for them that only they can see if they are all editor etc.

    So do you already have a PHP hook or action / filter for this in you repository of snippets so I can create a group (like a DL) for only the team use and visibility if they have been set as a specific role?

    Look forward to your update..

    Andrew

    #17254
    Shamim Hasan
    Keymaster

    So you want to restrict those groups so that only editor and administrator can see those group in user settings page, other users cannot see those groups in settings page (in front-end), right?

    #17256
    Andrew Perryman
    Participant

    Evening Shamim,

    Yes, but not restricting all groups only one or selected groups, otherwise it is as you have said so that I can create a group that will be listed in the person settings for Admin or Editors or contributors or what ever roles I choose only. So if I wanted to exclude subscribers or any other role I could for one or more specific groups.

    This then means when a new admin ,editor or contributor comes on board only they will see the extra groups listed in their settings amongst all the other pre created groups listed but not the standard members (users / subscribers role).

    Hope that clarify’s the situation.

    For clarification I have added two attachments for what I mean below, one as an Admin or designated roles and one as subscriber who will not see the group called management in their settings options.

    Andrew.

    Attachments:
    You must be logged in to view attached files.
    #17261
    Andrew Perryman
    Participant

    PS.. Oh and yes, for got to add only for the front-end..

    Andrew

    #17264
    Andrew Perryman
    Participant

    Oh, sorry one more thing…

    Just thought this would need to take effect in the users WP profile as I have just remembered that you give the option in the users WP profile to allow the them to add themselves to each group listed in that area too.

    Hope that makes sense..

    Andrew

    #17270
    Shamim Hasan
    Keymaster

    Add following code in your theme’s (child theme’s if any) functions.php

    add_filter( 'fep_get_option', function( $value, $option, $default, $is_default ) {
    	if ( 'gm_groups' !== $option ) {
    		return $value;
    	}
    	if ( is_admin() && 'users' !== @get_current_screen()->parent_base ) {
    		return $value;
    	}
    	if ( ! is_admin() && 'settings' !== @$_GET['fepaction'] ) {
    		return $value;
    	}
    	
    	// Change this with which role you want to give access to all groups
    	$allowed_roles = array( 'editor', 'administrator' );
    	
    	if ( array_intersect( $allowed_roles, wp_get_current_user()->roles ) ) {
    		return $value;
    	}
    	
    	// Change this with your desire groups slug
    	$groups = array( 'test1', 'test2' );
    	
    	foreach ( $groups as $group ) {
    		unset( $value[ $group ] );
    	}
    	
    	return $value;
    }, 10, 4 );
    

    Change roles and groups as required

    #17281
    Andrew Perryman
    Participant

    Shamim….. You Star.

    It works in all ways it hides all management groups from unauthorised roles..in the FEPM settings and in the Dashboard WP profile too unless force added which is even better than I expected.

    Fantastic.. You Rock dude..

    Andrew.. 🙂

Viewing 7 posts - 1 through 7 (of 7 total)

You need to purchase ‘Front End PM PRO’ to create topic in this support forum.

If you already purchased ‘Front End PM PRO’ please LOGIN.