admin管理员组文章数量:1425747
I have a simple plugin that Iam trying to use to learn OOP, please bear with me. I am setting up a part of it to show front end account data and want to grab the current user info. I know how to do this procedurally but I'm confused how to do this in OOP, I keep getting undefined function errors.
The structure for the class is set up as follows:
<?php
class FendAccount {
public $user;
public function __construct () {
}
public function set_user(){
}
} //END OF CLASS
$frontend = new FendAccount;
echo $frontend;
?>
This is in a separate class file that is being required by the main plugin PHP file and so should be firing as the plugin is loaded.
Am I rigght in thinking that a method that sets the property $user will be the best way to do this, so that I can call that method/object wherever I want in the plugin whenever I need to work with the current user? or is that overkill because wordpress already provides this functionality.
Or, should I just add a function to my main plugin PHP file that populates a global $current_user with the current user details via wp_get_current_user?
Thanks
本文标签: plugin developmentWordpress OOP get current user question
版权声明:本文标题:plugin development - Wordpress OOP get current user question? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745447150a2658715.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论