Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1316493

    Hello sir,
    Please help me hide the following marked (1,2,3,4) fields.
    Regards.

    #1316735

    Hey thomasgafo,

    Thanks for the screenshot. I’m not sure exactly what you are having problems with though?

    Best regards,
    Rikard

    #1316740

    Sir Rikard,
    I have customers (sellers) who create account and sell stuffs on my website so they have access to the admin.
    My problem is to hide some fields in the admin so they can not touch them. As you can see in the screenshot, the fields to be hidden are the one I surrounded in red.

    Thanks.

    #1317277

    Hi,

    Thank you for the update.

    The only box that the theme actually generates in that list is the Layout box, so that is the only box that we can toggle for now. For the other boxes such as the Open Graph and Product Description, you will have to contact the plugin authors.

    We can use the following filter in the functions.php file to control the visibility of the Layout box based on the current user.

    
    /* control builder boxes visibility */
    function add_builder_to_posttype($metabox)
    {
    	$user = wp_get_current_user();
    
    	foreach($metabox as &$meta)
    	{		
    		if($meta['id'] == 'layout' && in_array( 'author', (array) $user->roles ))
    		{
    			unset($meta['page']["product"]);
    		}
    	}
    
    	return $metabox;
    }
    add_filter('avf_builder_boxes', 'add_builder_to_posttype');
    

    The filter above disables the Layout box when the current user is an “author”.

    if($meta['id'] == 'layout' && in_array( 'author', (array) $user->roles ))
    

    You can also use the current_user_can function to check for the capability of the current user and go from there.

    // https://developer.wordpress.org/reference/functions/current_user_can/

    Best regards,
    Ismael

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