WordPress에서 Yoast SEO 플러그인을 사용하고 있으며 db 또는 functions.php 파일의 특정 사용자에게만 표시되도록하는 방법이 있는지 알고 싶습니까? 실제 사용자가 아닌 역할.특정 사용자에게만 표시되는 WordPress SEO 플러그인
0
A
답변
1
"플러그인 이름"을 추가하고 사용하지 않도록 설정했지만 범용 솔루션을 시도했지만 실패했습니다.
add_action('plugins_loaded', 'seo_so_25654837');
function seo_so_25654837()
{
if ('2' == get_current_user_id())
return;
remove_action('plugins_loaded', 'wpseo_admin_init', 15);
}
이
functions.php
에 코드를 추가
normal plugin로 사용하지 마십시오
그러나 만 특정 사용자 (
ID
가
2
와 동일), 다음 작품에 WPSEO를 표시합니다.
또한 관리자 표시 줄에서 검색 엔진 최적화 메뉴 제거하는 데 필요한 다음이 코드는 잘 작동
add_action('wp_before_admin_bar_render', 'bar_so_25654837');
function bar_so_25654837()
{
if ('2' == get_current_user_id())
return;
global $wp_admin_bar;
$nodes = $wp_admin_bar->get_nodes();
foreach($nodes as $node)
{
if(!$node->parent)
{
if('wpseo-menu' === $node->id)
$wp_admin_bar->remove_menu($node->id);
}
}
}
+0
굉장! 나는 PHP 코드로 플러그인을 만들었고 완벽하게 작동합니다. 당신의 도움을 주셔서 감사합니다. – Brendan
0
테이블에 표시되기 전에 요소를 제거하려면 pre_current_active_plugins
에 연결할 수 있습니다. 함수 내에서 get_current_user_id()
을 사용하면 선택적으로 플러그인을 숨길 수 있습니다.
function hide_plugins_by_user($all_plugins=false) {
global $wp_list_table;
// if the current user ID is not 1, hide it.
if (1 != get_current_user_id()){
// the active plugins from the table
$plugins = $wp_list_table->items;
// loop through them
foreach ($plugins as $key => $val) {
// use the dir + filename of the plugin to hide
if ($key == 'plugindir/plugin.php') {
unset($wp_list_table->items[$key]);
}
}
}
}
add_action('pre_current_active_plugins', 'hide_plugins_by_user');
0
(크레딧 Hislop로 이동) :
// Returns true if user has specific role
function check_user_role($role, $user_id = null) {
if (is_numeric($user_id))
$user = get_userdata($user_id);
else
$user = wp_get_current_user();
if (empty($user))
return false;
return in_array($role, (array) $user->roles);
}
// Disable WordPress SEO meta box for all roles other than administrator and seo
function wpse_init(){
if(!(check_user_role('seo') || check_user_role('administrator'))){
// Remove page analysis columns from post lists, also SEO status on post editor
add_filter('wpseo_use_page_analysis', '__return_false');
// Remove Yoast meta boxes
add_action('add_meta_boxes', 'disable_seo_metabox', 100000);
}
}
add_action('init', 'wpse_init');
function disable_seo_metabox(){
remove_meta_box('wpseo_meta', 'post', 'normal');
remove_meta_box('wpseo_meta', 'page', 'normal');
}
을 단지에 배치 functions.php 파일.
0
모든 사용자의 Yoast를 비활성화하고 몇 가지 또는 특정 용도로만 사용하려면 function.php 파일에 다음 코드를 추가하십시오.
function remove_wpseo(){
/* if you want to keep it enabled for user with id 2 */
if ('2' == get_current_user_id()) {
return;
}
global $wpseo_front;
if(defined($wpseo_front)){
remove_action('wp_head',array($wpseo_front,'head'),1);
}
else {
$wp_thing = WPSEO_Frontend::get_instance();
remove_action('wp_head',array($wp_thing,'head'),1);
}
}
add_action('template_redirect','remove_wpseo');
참조 :`get_current_user_id`의 그것 : https://makersbyte.com/disable-yoast-seo-plugin-specific-page/ 내 머리의 상단에서
관련 문제
- 1. Wordpress - 특정 사용자에게만 표시되는 메시지
- 2. YOast SEO 플러그인 감지
- 3. 특정 트윗을위한 wordpress 플러그인
- 4. 특정 사용자에게만 업데이트 출력
- 5. 일치하는 사용자에게만 표시되는 MVC 테이블 행
- 6. Wordpress 정적 페이지 'SEO'?
- 7. SEO 도움말 | Wordpress
- 8. Wordpress SEO 기능
- 9. Wordpress multisite seo
- 10. Wordpress SEO Plugin isue
- 11. 페이지에서 Yoast WordPress SEO 제거
- 12. WordPress 플러그인 존재 여부 확인
- 13. Socket.io - 특정 사용자에게만 방출 하시겠습니까?
- 14. 특정 사용자에게만 ASPxGridView 편집 허용
- 15. 로그인 한 사용자에게만 WordPress 페이지를 표시하는 방법?
- 16. 콘텐츠 페이지에서 특정 카테고리를 출력하는 WordPress 플러그인
- 17. 구글에 특정 도메인 SEO
- 18. PHP Wordpress SEO 페이지 제목 도움?
- 19. 회원 용 Wordpress 플러그인?
- 20. jquery를 사용하는 Wordpress 플러그인
- 21. Wordpress 플러그인 페이지 라우팅
- 22. Wordpress 플러그인 경로 설정
- 23. drupal 업데이트 된 기사가 로그인 한 사용자에게만 표시되는 이유는 무엇입니까?
- 24. jQuery 히스토리 플러그인, Google Sitemap 및 SEO
- 25. 특정 FB 사용자에게만 앱 액세스 허용
- 26. 특정 사용자에게만 팝업으로 요소를 여는 방법
- 27. ActiveAdmin 레일의 특정 사용자에게만 다운로드 링크를 표시해야합니까?
- 28. 자동차 수리 예약 WordPress 플러그인
- 29. SEO 용 WordPress 카테고리/태그를 어떻게 구성해야합니까?
- 30. Wordpress 사이트의 robots.txt 파일을 변경하는 SEO 혼란
, 당신처럼, 현재 사용자의 ID를 확인하는 기능을 가진 기능은 일정한를 확인하는 기능을 대체 할 수 그냥 if와 if 그리고 ID. –