フォームビルダーのマーケティングタブを非表示にする方法

フォームビルダーのマーケティングタブを非表示にしたいですか?もしあなたのサイトに様々なロールを持ったユーザーがいて、アクセスコントロールを使ってWPForms にアクセスできるようにしている場合、フォームに統合機能を設定させたくないかもしれません。このチュートリアルでは、小さなPHPスニペットを使って簡単にマーケティングタブを非表示にする方法を紹介します!

マーケティング」タブの非表示

デフォルトでは、適切な権限を持つユーザーであれば誰でも、WPForms フォームビルダーを使用してサイト上にフォームを作成できます。

フォームビルダーのタブがデフォルトのビューに表示される

このチュートリアルでは、WordPress のロールが「購読者」または「編集者」であるすべてのユーザーに対して、フォームビルダーの「マーケティング」タブを非表示にしたいと思います。これを実現するには、このスニペットをサイトにコピーする必要があります。

あなたのサイトにスニペットを追加する方法と場所についてサポートが必要な場合は、こちらのチュートリアルをご覧ください

/**
 * Hide the Marketing tab inside the form builder
 *
 * @link   https://wpforms.com/developers/how-to-hide-the-marketing-tab-in-form-builder/
 */

function hide_marketing_tab_based_on_role() {
	
	// Default WordPress User Roles: subscriber, editor, contributor, author, administrator
	// For more information on WordPress roles check out https://wordpress.org/documentation/article/roles-and-capabilities/ 
	
	// Check if the current user is a subscriber OR an editor 
	if( current_user_can( 'subscriber' ) || current_user_can( 'editor' ) ) {
		echo '<style>
				.wpforms-panel-providers-button {
				  display: none !important;
				} 
			  </style>';
	}
}

add_action('admin_head', 'hide_marketing_tab_based_on_role');

WordPressのユーザーロールと機能の詳細については、WordPressのドキュメントをご覧ください

スニペットを追加したら、「マーケティング」タブを非表示にできます。

これだけで、特定のロールを持つWordPressユーザーからマーケティングタブを隠すことができます。フォームにカラーピッカーを追加したいですか?フォームにカラーピッカーを追加する方法のチュートリアルをご覧ください。

よくあるご質問

Q: 「支払い」タブも非表示にできますか?

A: 「支払い」タブも非表示にしたい場合。

/**
 * Hide the Payments tab inside the form builder
 *
 * @link   https://wpforms.com/developers/how-to-hide-the-marketing-tab-in-form-builder/
 */

function hide_payments_tab_based_on_role() {
	
	// Default WordPress User Roles: subscriber, editor, contributor, author, administrator
	// For more information on WordPress roles check out https://wordpress.org/documentation/article/roles-and-capabilities/ 
	
	// Check if the current user is a subscriber OR an editor 
	if( current_user_can( 'subscriber' ) || current_user_can( 'editor' ) ) {
		echo '<style>
				.wpforms-panel-payments-button {
				  display: none !important;
				} 
			  </style>';
	}
}

add_action('admin_head', 'hide_payments_tab_based_on_role');

Q: 両方のタブを隠すことはできますか?

A:このスニペットを使えば、両方のタブを隠すことができます。

/**
 * Hide the Payments and Marketing tab inside the form builder
 *
 * @link   https://wpforms.com/developers/how-to-hide-the-marketing-tab-in-form-builder/
 */

function hide_marketing_tab_based_on_role() {
	
	// Default WordPress User Roles: subscriber, editor, contributor, author, administrator
	// For more information on WordPress roles check out https://wordpress.org/documentation/article/roles-and-capabilities/ 
	
	// Check if current user is subscriber OR editor 
	if( current_user_can( 'subscriber' ) || current_user_can( 'editor' ) ) {
		echo '<style>
				.wpforms-panel-providers-button {
				  display: none !important;
				} 
				.wpforms-panel-payments-button {
				  display: none !important;
				}
			  </style>';
	}
}

add_action('admin_head', 'hide_marketing_tab_based_on_role');