WordPress自定义角色已损坏

我试图用这行代码创建一个自定义角色。但问题是,当我创建一个没有名字的角色时。然后,当我去编辑它时,我被引导到一个错误页面,上面说\"请求编辑的角色不存在。\"我无法删除该角色。我只想摆脱我创造的角色。我可以让代码运行写,但这个代码给了我破碎的角色。我正在使用一个表单插件,它从前端填充自定义字段,因此当您点击submit时,它将运行下面的代码。 function wpufe_update_post_price( $post_id = get_post_meta( $post_id, \"manager_password\",> I\"m not sure it\"s possible to create a role with no name. Its data may be corrupted such that the related UI does not function correctly, but AFAIK there has to be a name. Anyway, you could use some custom PHP code to get the \"wp_user_roles\" option. Var_dump the returned array and determine the array key used for the offending role (the role\"s actual name slug). Unset the offending array element, then save the remaining array back to the option. I recommend backing up the options table, or at least that one option before making such a low level change. Don\"t attempt to directly alter the option value through phpMyAdmin, the data structure used is generally too finicky to allow for successful manual editing. A bit off topic, but it doesn\"t seem correct to create specifically named roles and users every time the \"wpufe_update_post_price\" fires. Addition of the same role and users will be attempted any time any post\"s price is updated, when the addition only needs to be done once. Adding persistent data like roles and users is typically done only once when the related plugin is activated. Even then, it\"s good practice to verify such role and users do not exist before trying to add them. @bcworkz so I should make a custom code that gets an array of all the roles finds the ones I want to delete and delete them thru custom code. Also the code above isn\"t finished for each role or user it will be name manager, name sever, etc. That\"s what I suggest. The code ought to be somewhere you can manually control. I like to use a custom page template tied to a single page for things like that. Name the template file following the formats 1-3 outlined in the Theme Handbook. You can start with a copy of your theme\"s general singular templates (files 4-6 in the above link). Make it a private page to keep search bots from trying to use it. I figured it is a work in progress, that\"s fine, but I still question if you\"d want to create new roles and users every time a post\"s price is updated, regardless of their names. If that\"s really what you want, so be it, it\"s your site, not mine @bcworkz So i got it working and deleted the roles I wanted. Then I went back edited the code a little and most of the time I get a role that has a display name but still sometimes when I use the code below I still get a blank display name. I am also unable to delete the new roles = lcfirst($role);add_role( $role, __( $name ), get_role ( \"restaurant_template\" )->capabilities ); 与之前一样,我解决了旧角色的删除问题,但这次我无法使其正常工作。角色将不再删除。我已尝试将removeu role($role)替换为removeu role(\"role to delete\"),但无效。我不知道发生了什么,但我只调用了add role来创建一个角色。 @bcworkz我发现,如果我创建了一个表单,并且餐厅名称中有一个空格,比如\"big boy\",那么它就不能用作显示名称。如果它是\"大男孩\",它会工作。我不知道为什么。但是我尝试添加下面的代码来去掉空格,但是仍然留下一个空白角色> translateu useru role()做什么?我想这是你麻烦的根源。这不起作用:**1***。转换方案只适用于固定字符串,而不适用于变量。而且翻译是预先编译好的,你不能像我想的那样即时翻译。 @bcworkz所以只调用translateu useru角色来呼应名称。我不相信它对变量有什么影响。但我会删除它然后再试。我还要重新编写它,因为add_role( $role, ( $name ), get_role ( \"restaurant_template\" )->capabilities ); @bcworkz没有删除角色。我不知道是什么原因造成了这些坏消息,这个回复是5个月前,2个星期前被lex713修改的,可能是名字中有一个奇怪的字符导致了通常的删除方法的失败?IDK公司。尝试我最初建议的低级方法: …获取\"wpu useru roles\"选项。Varu转储返回的数组并确定用于违规角色的数组键(角色的实际名称slug)。取消设置有问题的数组元素,然后将剩余的数组保存回选项。 如果要将所有角色重置回默认值,可以从干净的安装中获取选项值的副本,并通过phpMyAdmin的两个实例将其复制到站点。一个用于清洁站点,另一个用于您的站点

admin_action_{$_REQUEST[‘action’]}

do_action( "admin_action_{$_REQUEST[‘action’]}" )动作钩子::在发送“Action”请求变量时激发。Action Hook: Fires when an ‘action’ request variable is sent.目录锚点:#说明#源码说明(Description)钩子名称的动态部分$_REQUEST['action']引用从GET或POST请求派生的操作。源码(Source)更新版本源码位置使用被使用2.6.0 wp-admin/admin.php:...

日期:2020-09-02 17:44:16 浏览:1159

admin_footer-{$GLOBALS[‘hook_suffix’]}

do_action( "admin_footer-{$GLOBALS[‘hook_suffix’]}", string $hook_suffix )操作挂钩:在默认页脚脚本之后打印脚本或数据。Action Hook: Print scripts or data after the default footer scripts.目录锚点:#说明#参数#源码说明(Description)钩子名的动态部分,$GLOBALS['hook_suffix']引用当前页的全局钩子后缀。参数(Parameters)参数类...

日期:2020-09-02 17:44:20 浏览:1060

customize_save_{$this->id_data[‘base’]}

do_action( "customize_save_{$this->id_data[‘base’]}", WP_Customize_Setting $this )动作钩子::在调用WP_Customize_Setting::save()方法时激发。Action Hook: Fires when the WP_Customize_Setting::save() method is called.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分,$this->id_data...

日期:2020-08-15 15:47:24 浏览:799

customize_value_{$this->id_data[‘base’]}

apply_filters( "customize_value_{$this->id_data[‘base’]}", mixed $default )过滤器::过滤未作为主题模式或选项处理的自定义设置值。Filter Hook: Filter a Customize setting value not handled as a theme_mod or option.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分,$this->id_date['base'],指的是设置...

日期:2020-08-15 15:47:24 浏览:885

get_comment_author_url

过滤钩子:过滤评论作者的URL。Filter Hook: Filters the comment author’s URL.目录锚点:#源码源码(Source)更新版本源码位置使用被使用 wp-includes/comment-template.php:32610...

日期:2020-08-10 23:06:14 浏览:925

network_admin_edit_{$_GET[‘action’]}

do_action( "network_admin_edit_{$_GET[‘action’]}" )操作挂钩:启动请求的处理程序操作。Action Hook: Fires the requested handler action.目录锚点:#说明#源码说明(Description)钩子名称的动态部分$u GET['action']引用请求的操作的名称。源码(Source)更新版本源码位置使用被使用3.1.0 wp-admin/network/edit.php:3600...

日期:2020-08-02 09:56:09 浏览:871

network_sites_updated_message_{$_GET[‘updated’]}

apply_filters( "network_sites_updated_message_{$_GET[‘updated’]}", string $msg )筛选器挂钩:在网络管理中筛选特定的非默认站点更新消息。Filter Hook: Filters a specific, non-default site-updated message in the Network admin.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分$_GET['updated']引用了非默认的...

日期:2020-08-02 09:56:03 浏览:854

pre_wp_is_site_initialized

过滤器::过滤在访问数据库之前是否初始化站点的检查。Filter Hook: Filters the check for whether a site is initialized before the database is accessed.目录锚点:#源码源码(Source)更新版本源码位置使用被使用 wp-includes/ms-site.php:93910...

日期:2020-07-29 10:15:38 浏览:825

WordPress 的SEO 教学:如何在网站中加入关键字(Meta Keywords)与Meta 描述(Meta Description)?

你想在WordPress 中添加关键字和meta 描述吗?关键字和meta 描述使你能够提高网站的SEO。在本文中,我们将向你展示如何在WordPress 中正确添加关键字和meta 描述。为什么要在WordPress 中添加关键字和Meta 描述?关键字和说明让搜寻引擎更了解您的帖子和页面的内容。关键词是人们寻找您发布的内容时,可能会搜索的重要词语或片语。而Meta Description则是对你的页面和文章的简要描述。如果你想要了解更多关于中继标签的资讯,可以参考Google的说明。Meta 关键字和描...

日期:2020-10-03 21:18:25 浏览:1691

谷歌的SEO是什么

SEO (Search Engine Optimization)中文是搜寻引擎最佳化,意思近于「关键字自然排序」、「网站排名优化」。简言之,SEO是以搜索引擎(如Google、Bing)为曝光媒体的行销手法。例如搜寻「wordpress教学」,会看到本站的「WordPress教学:12个课程…」排行Google第一:关键字:wordpress教学、wordpress课程…若搜寻「网站架设」,则会看到另一个网页排名第1:关键字:网站架设、架站…以上两个网页,每月从搜寻引擎导入自然流量,达2万4千:每月「有机搜...

日期:2020-10-30 17:23:57 浏览:1296