• Resolved tezalsec

    (@tezalsec)


    Hi, I would like to hide the TSF box on CPT edit pages for non-admin users, can you tell me what the name of the box is I need to use. I tried below but it won’t work.

    function remove_meta_boxes() {
    
        if ( !current_user_can('update_core')) {
    
            # Removes meta from Posts #
            remove_meta_box( 'tsf-inpost-box','post','normal');     
        }
    }
    add_action('admin_init','remove_meta_boxes');

    And the same for the column in admin table, please.

    It is not:

    unset($columns[‘tsf-seo-bar-wrap’]);

    Thank you.

    • This topic was modified 3 years ago by tezalsec.
    • This topic was modified 3 years ago by tezalsec.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hello!

    Try this snippet; it’ll take care of hiding everything all at once:

    add_action( 
    	'plugins_loaded',
    	function() {
    		if ( ! current_user_can( 'update_core' ) )
    			define( 'THE_SEO_FRAMEWORK_HEADLESS', true );
    	},
    	4
    );

    This snippet works in a plugin or mu-plugin only, not in a theme, for they load after plugins are loaded.

    For details, please see https://tsf.fyi/kb/headless.

    Thread Starter tezalsec

    (@tezalsec)

    Works like a charm, thanks a lot! ??

    Plugin Author Sybre Waaijer

    (@cybr)

    Hi again!

    Sorry about this, but I missed condition: is_admin(). Without it, headless mode would also be enabled on the front-end, causing search engines and visitors to miss the administrator’s custom metadata, redirects, and plugin settings. Please update your snippet with the one below:

    add_action( 
    	'plugins_loaded',
    	function() {
    		if ( is_admin() && ! current_user_can( 'update_core' ) )
    			define( 'THE_SEO_FRAMEWORK_HEADLESS', true );	
    	}, 
    	4 
    );

    Cheers! ??

    Thread Starter tezalsec

    (@tezalsec)

    Ok, I added it, thanks!

    Maybe it’s an idea to create an extra THE_SEO_FRAMEWORK_HEADLESS_BACKEND constant for this purpose, so people won’t make the mistake not checking the is_admin() condition.

    Cheers.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Hide TSF metabox’ is closed to new replies.