wordpress用户注册_为用户简化WordPress的7种方法

本文介绍了如何为不常使用WordPress或技术能力有限的用户简化其体验。包括授予合适的用户角色,创建高级功能的简码,移除更新通知,删除冗余菜单,隐藏不必要的页面和发布元框,移除不必要仪表板小部件以及去除管理栏。这些方法有助于保护网站并提高用户效率。
摘要由CSDN通过智能技术生成

wordpress用户注册

simpler WordPress

This article is part of a series created in partnership with SiteGround. Thank you for supporting the partners who make SitePoint possible.

本文是与SiteGround合作创建的系列文章的一部分。 感谢您支持使SitePoint成为可能的合作伙伴。

WordPress is one of the simpler Content Management Systems. Despite its clean user interface, WordPress can be daunting for those who use it infrequently or have basic IT skills. It also offers considerable power; it’s easy to install a malicious plugin or wipe a database if you’re not careful.

WordPress是较为简单的内容管理系统之一。 尽管WordPress的用户界面干净利落,但对于那些不经常使用它或具有基本IT技能的人来说,它可能会令人生畏。 它还提供了强大的功能。 如果您不小心,很容易安装恶意插件或清除数据库。

Fortunately, WordPress can be configured and customized to save users from themselves! That includes the person in every organization who vastly over-estimates their technical prowess…

幸运的是,可以对WordPress进行配置和自定义,以使用户免于自己! 这包括每个组织中大大高估其技术能力的人……

1.授予适当的用户角色 (1. Grant Appropriate User Roles)

WordPress offers a range of roles and capabilities. In most cases, users should either be:

WordPress提供了一系列角色和功能 。 在大多数情况下,用户应为:

  • an Editor: someone who can publish and manage their own and other people’s posts.

    编辑者 :可以发布和管理自己和其他人的帖子的人。

  • an Author: someone who can publish and manage their own posts.

    作者 :可以发布和管理自己的帖子的人。

  • a Contributor: someone who can write and manage their own posts but cannot publish them.

    贡献者 :可以撰写和管理自己的帖子但不能发布的人。

None of these roles can install plug-ins, change themes, approve updates, edit files or perform other dangerous tasks available to Administrators. Of course, some users will claim they need full rights — that’s fine if they’re prepared to take the risk and pay the cost of losing everything!

这些角色均不能安装插件,更改主题,批准更新,编辑文件或执行管理员可用的其他危险任务。 当然,有些用户会声称他们需要完整的权限-如果他们准备冒险承担一切损失的费用,那就很好了!

2.创建用于高级功能的简码 (2. Create Shortcodes for Advanced Functionality)

Users often demand advanced functionality such as Twitter widgets, stock price trackers, affiliate links, etc. Rather than let them add arbitrary third-party code, allow them to call your code via a shortcode defined in a plugin or the theme’s functions.php file:

用户通常需要高级功能,例如Twitter窗口小部件,股价跟踪器,会员链接等。与其让他们添加任意第三方代码,不如让他们通过在插件或主题的functions.php文件中定义的短代码来调用您的代码。 :

// include a specific PHP file
function customIncludeFile($params = array()) {

	extract(shortcode_atts(array(
	    'file' => 'contact-form'
	), $params));

	ob_start();
	include(get_theme_root() . '/' . get_template() . "/$file.php");
	return ob_get_clean();
}

add_shortcode('include', 'customIncludeFile');

This shortcode allows users to enter [include myfile] in the editor to include myfile.php from the template folder.

此短代码允许用户在编辑器中输入[include myfile] ,以从模板文件夹中包含myfile.php

3.删除WordPress更新通知 (3. Remove WordPress Update Notifications)

A WordPress update notification may be useful to you but could worry your users. Disable it in a plugin or the theme’s functions.php file:

WordPress更新通知可能对您有用,但可能会使您的用户担心。 在插件或主题的functions.php文件中将其禁用:

// remove update notifications
<?php
function no_update_notification() {
	if (!current_user_can('activate_plugins')) remove_action('admin_notices', 'update_nag', 3);
}
add_action('admin_notices', 'no_update_notification', 1);

4.删除不必要的菜单 (4. Remove Unnecessary Menus)

Few sites use every WordPress feature. For example, your installation may not need commenting functionality. Unnecessary items can be removed with the following code in a plugin or functions.php:

很少有站点使用每个WordPress功能。 例如,您的安装可能不需要注释功能。 可以使用以下代码在plugin或functions.php中删除不必要的项:

// remove unnecessary menus
function remove_admin_menus () {
	global $menu;

	// all users
	$restrict = explode(',', 'Links,Comments');

	// non-administrator users
	$restrict_user = explode(',', 'Media,Profile,Users,Tools,Settings');

	// WP localization
	$f = create_function('$v,$i', 'return __($v);');
	array_walk($restrict, $f);
	if (!current_user_can('activate_plugins')) {
		array_walk($restrict_user, $f);
		$restrict = array_merge($restrict, $restrict_user);
	}

	// remove menus
	end($menu);
	while (prev($menu)) {
		$k = key($menu);
		$v = explode(' ', $menu[$k][0]);
		if(in_array(is_null($v[0]) ? '' : $v[0] , $restrict)) unset($menu[$k]);
	}

}
add_action('admin_menu', 'remove_admin_menus');

Set the following variables accordingly:

相应地设置以下变量:

  • $restrict — a comma-delimited list of menu items which will not be shown to any users, including administrators. In the example above, we’re hiding Links and Comments.

    $ restrict —菜单项的逗号分隔列表,不会显示给任何用户,包括管理员。 在上面的示例中,我们隐藏了链接和评论。

  • $restrict_user — a comma-delimited list of menu items which will not be shown to non-administrators. The example above disables everything except the Dashboard, Pages and Posts. Appearance and Plugins would also be hidden by default for non-administrators.

    $ restrict_user —菜单项的逗号分隔列表,不会向非管理员显示。 上面的示例禁用了“仪表板”,“页面”和“帖子”以外的所有内容。 对于非管理员,默认情况下还将隐藏外观和插件。

5.删除不必要的页面和发布元框 (5. Remove Unnecessary Page and Post Meta Boxes)

Few people — even administrators — require all the options available to pages, posts and custom posts. These can be hidden using the Screen Options menu at the top-right of the editing screen but users can still re-enable options. You can remove the boxes permanently by adding the following code to a plugin or functions.php:

很少有人- 甚至是管理员 -都需要页面,帖子和自定义帖子可用的所有选项。 可以使用编辑屏幕右上方的“ 屏幕选项”菜单隐藏这些选项 ,但用户仍可以重新启用选项。 您可以通过将以下代码添加到plugin或functions.php中来永久删除这些框:

// remove unnecessary page/post meta boxes
function remove_meta_boxes() {

	// posts
	remove_meta_box('postcustom','post','normal');
	remove_meta_box('trackbacksdiv','post','normal');
	remove_meta_box('commentstatusdiv','post','normal');
	remove_meta_box('commentsdiv','post','normal');
	remove_meta_box('categorydiv','post','normal');
	remove_meta_box('tagsdiv-post_tag','post','normal');
	remove_meta_box('slugdiv','post','normal');
	remove_meta_box('authordiv','post','normal');

	// pages
	remove_meta_box('postcustom','page','normal');
	remove_meta_box('commentstatusdiv','page','normal');
	remove_meta_box('trackbacksdiv','page','normal');
	remove_meta_box('commentsdiv','page','normal');
	remove_meta_box('slugdiv','page','normal');
	remove_meta_box('authordiv','page','normal');

}
add_action('admin_init','remove_meta_boxes');

Add or remove remove_meta_box lines as necessary. The first argument is the ID assigned to the metabox’s div element — locate that in the HTML source or using Developer Tools.

根据需要添加或删除remove_meta_box行。 第一个参数是分配给metabox的div元素的ID-在HTML源代码中或使用开发人员工具定位该ID。

6.删除不必要的仪表板小部件 (6. Remove Unnecessary Dashboard Widgets)

Similarly, the dashboard can offer a bewildering array of options to some users. Remove dashboard widgets with the following plugin or functions.php code:

同样,仪表板可以为某些用户提供一系列令人困惑的选项。 使用以下插件或functions.php代码删除仪表板小部件:

// remove unnecessary dashboard widgets
function remove_dashboard_widgets(){

	global $wp_meta_boxes;

	// only remove "Right Now" for non-administrators
	if (!current_user_can('activate_plugins')) {
		unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
	}

	// remove widgets for everyone
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);

}
add_action('wp_dashboard_setup', 'remove_dashboard_widgets');

This can be configured as necessary. The dashboard widget’s ID is assigned to its div element — locate that in the HTML source or using Developer Tools.

可以根据需要进行配置。 仪表板小部件的ID已分配给其div元素-在HTML源代码中或使用开发人员工具定位它。

7.卸下管理栏 (7. Remove the Administration Bar)

WordPress shows a dark grey administration bar at the top of your live site when logged in. You may not find it useful. Or perhaps your users think all visitors can see the bar? You can remove it with a line of PHP in your plugin or functions.php code:

WordPress登录后在活动站点的顶部显示一个深灰色的管理栏。您可能会发现它没有用。 还是您的用户认为所有访客都可以看到该栏? 您可以在插件或functions.php代码中使用一行PHP删除它:

// remove admin bar
add_filter('show_admin_bar', '__return_false');

Do you have other recommendations for simplifying WordPress?

您还有其他简化WordPress的建议吗?

翻译自: https://www.sitepoint.com/make-wordpress-simpler-users/

wordpress用户注册

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值