尋找與get_user_option/update_user_optionWordPress插件中的get_option和get_user_option有什麼區別?
我創建了WordPress的一個新的插件,我不知道我是否應該使用設置頁面的user_option或只是簡單的選項使用get_option/update_option之間的差異。
我應該使用哪種方案,而不是其他方案。
感謝
尋找與get_user_option/update_user_optionWordPress插件中的get_option和get_user_option有什麼區別?
我創建了WordPress的一個新的插件,我不知道我是否應該使用設置頁面的user_option或只是簡單的選項使用get_option/update_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來實現影響所有用戶的一般設置,並且每個用戶都不能爲自己設置個人身份。
Wp的get_user_options https://codex.wordpress.org/Function_Reference/get_user_option
Wp的update_user_option https://codex.wordpress.org/Function_Reference/update_user_option
我知道的wordpress的文件是很難理解,如果你也面臨同樣的問題,讓我知道我會解釋用我自己的話。 :)
get_option是使用掛鉤可以被任何用戶使用像
<h1><?php echo get_option('blogname'); ?></h1>
get_user_option的東西被用來將所有像用戶可用的編緝選項。
對不起,我是新來這個網站我不能夠添加PHP代碼:'(
我知道我的例子是不符合邏輯的bcuz只有管理員可以訪問該面板:d
我明白如何爲你get_user_options和update_user_options。我的問題是爲什麼我會選擇使用get_user_option和get_option。 Wordpress並沒有解釋兩者之間的區別,以及我應該什麼時候選擇一個。 https://codex.wordpress.org/Function_Reference/get_option https://codex.wordpress.org/Function_Reference/get_user_option – jsherk