• Resolved korbball

    (@korbball)


    Hi

    I’d like to remove the Detail box in Team backend page. I have already used this Code:

    add_action('admin_init', 'wpse_110427_hide_title');
    function wpse_110427_hide_title() {
     if (current_user_can('sp_team_manager'))
         remove_post_type_support('sp_team', 'title');
    
    }

    to remove the post title (Team Name)

    Do you have a way to hide some other meta in backend? Something like:

    remove_post_type_support('sp_team', 'DETAILS');
    remove_post_type_support('sp_team', 'LOGO');

    best regards
    korbball

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Savvas

    (@savvasha)

    Hi @korbball ,

    Did you try any 3nd party plugin like User Role Editor?

    Thanks,
    Savvas

    Thread Starter korbball

    (@korbball)

    Hi Savvas

    I it is possible to hide the wit AAM but when I hide the Detail – ist not possible for the usere for example to select a league table and Show it on the Team page. so it disable this Funktion too. It is not a Problem of the capabilities.

    I’ve tried this codes from plugintests.com

    function plt_hide_sportspress_metaboxes() {
    	$screen = get_current_screen();
    	if ( !$screen ) {
    		return;
    	}
    	//Hide the "Details" meta box.
    	remove_meta_box('sp_detailsdiv', $screen->id, 'side');
    
    }
    
    add_action('add_meta_boxes', 'plt_hide_sportspress_metaboxes', 20);

    But it doesnt work. I’dont know why it is not possible to hide this meta.
    I’d like to have a Code snipet to insert in the funktions.php file.

    best regards
    korbball

    Thread Starter korbball

    (@korbball)

    Hi Savvas

    I had to made something like a work around, because If I remove the spdetails_div it “forgot” the details after updateing an event or team.

    Howerver, this is the workaroud I’m using now:
    1. Uncheck boxes for the “unnessesary” metaboxes
    2. Hide the “Screen Options” for spesific users

    // Funktion w?hlt alle Metaboxen aus, die Verdeckt werden sollen.
    // Function choose all metaboxes which shall disappear
    add_filter('hidden_meta_boxes', 'hide_meta_box_attributes', 10, 2);
    function hide_meta_box_attributes( $hidden, $screen) {
        $hidden = [
    		'pageparentdiv', //Seitenatribute
    		'sp_detailsdiv', //Team Details
    		'postimagediv', //Team Logo
    		'sp_staffdiv', //Stafflist
    		'sp_listsdiv', //Playerlist
    		'postexcerpt', //Excerpt (Auszug)
    		'slugdiv', //Titelform		
    			  ];
        return $hidden;
    } 
    
    // Hide Screen Options for all users without "manage_options" capability
    // Ansicht anpassen wird für alle ausgeblendet ausser für Benutzer die manage_options haben.
    add_filter('screen_options_show_screen', 'remove_screen_options');
    function remove_screen_options(){
       if(!current_user_can('manage_options')) {
    	   return false;
       }
    	return true; 
    }
    
    // Entfernt Editor und Titel bei Teams für Mannschaftsführer
    // Removes editor and title on team pages (team manager shall not change this data!)
    add_action('admin_init', 'sp_team_hide_editor');
    function sp_team_hide_editor() {
     if (!current_user_can('manage_options'))
         remove_post_type_support('sp_team', 'title');
    	 remove_post_type_support('sp_team', 'editor');
    }

    The code is in the functions.php file of the child theme. Using Code Snippets would work too.

    Maybe you have another and better solution.

    best regards
    korbball

    • This reply was modified 5 years, 2 months ago by korbball.
    Roch

    (@rochesterj)

    Hi korbball, that’s a great solution, thanks for sharing.

    Since this isn’t part of our core functions (and isn’t support), I’ll flag this as resolved. But savvas can always tag along and check this or share his thoughts.

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Remove backend team details for users’ is closed to new replies.