WordPress插件中的get_option和get_user_option有什么区别?
What is the difference between get_option and get_user_option in WordPress plugin?
寻找使用 get_option/update_option 与 get_user_option/update_user_option
之间的区别
我正在为 Wordpress 创建一个新插件,但不确定我是否应该使用 user_option 或设置页面的简单选项。
我应该在哪些场景中使用一种,而不是另一种。
谢谢
当我通读每一个的描述时,这是我的看法:
https://codex.wordpress.org/Function_Reference/get_option
https://codex.wordpress.org/Function_Reference/get_user_option
get_option 似乎是一个设置一次的全局选项,所有用户总是会得到相同的值。它可能由管理员设置,用户无法自行更改设置。
get_user_option 是用户特定值,因此如果一个用户设置了它,则不会为另一个用户设置。每个用户都会为它设置自己唯一的值。
因此,您很可能希望使用 get_option 和 update_option 进行通用设置,该设置对所有用户的影响相同,并且每个用户都不能为自己单独设置。
寻找使用 get_option/update_option 与 get_user_option/update_user_option
之间的区别我正在为 Wordpress 创建一个新插件,但不确定我是否应该使用 user_option 或设置页面的简单选项。
我应该在哪些场景中使用一种,而不是另一种。
谢谢
当我通读每一个的描述时,这是我的看法:
https://codex.wordpress.org/Function_Reference/get_option
https://codex.wordpress.org/Function_Reference/get_user_option
get_option 似乎是一个设置一次的全局选项,所有用户总是会得到相同的值。它可能由管理员设置,用户无法自行更改设置。
get_user_option 是用户特定值,因此如果一个用户设置了它,则不会为另一个用户设置。每个用户都会为它设置自己唯一的值。
因此,您很可能希望使用 get_option 和 update_option 进行通用设置,该设置对所有用户的影响相同,并且每个用户都不能为自己单独设置。