官术网_书友最值得收藏!

Introduction to user management

Usually, other popular PHP development frameworks such as Zend, CakePHP, CodeIgniter, and Laravel don't provide built-in user modules. Developers tend to build their own user management modules and use them across many projects of the same framework. WordPress offers a built-in user management system to cater to common user management tasks in web applications. Such things include:

  • Managing user roles and capabilities
  • Built-in user registration
  • Built-in user login
  • Built-in forgot password

Developers are likely to encounter these tasks in almost all web applications. On most occasions, these features and functions can be effectively used without significant changes to the code. However, web applications are much more advanced, and hence we might need various customizations on these existing features. It's important to explore the possibility of extending these functions so that they are compatible with advanced application requirements. In the upcoming sections, we are going to learn how to extend these common functionalities to suit varying scenarios.

Preparing the plugin

As developers, we have the option of building a complete application with standalone plugins or using various independent plugins to cater for specific modules. Throughout this book, we will be developing several independent modules as specific plugins to make things simple. We are going to create a specific plugin for user-related functionalities of our application. So, let's get started by creating a new folder named wpwa_user_manager inside the /wp-content/plugins folder.

Then, create a PHP file inside the folder and save it as class-wpwa-user-manager.php. Now it's time to add the plugin definition as shown in the following code:

<?php
/*
  Plugin Name: WPWA User Manager
  Plugin URI:
  Description: User management module for the portfolio management application.
  Author: Rakhitha Nimesh
  Version: 1.0
  Author URI: http://www.innovativephp.com/
*/

In the previous chapter, we created a plugin with procedural functions calls. Now we are going to go one step further by building an object-oriented plugin. Basically, this plugin consists of one main class that handles the plugin initialization. The following code shows the implementation of the plugin class inside the wpwa-user-manager.php file:

class WPWA_User_Manager {
  public function __construct() {
    // Initialization code
  }
}
$user_manege = new WPWA_User_Manager();

Once the class is defined, we can make an object to initialize the plugin within the same file. All the initialization code resides in the plugin constructor.

主站蜘蛛池模板: 巴彦县| 客服| 乐安县| 泽普县| 华容县| 乌拉特前旗| 全椒县| 固阳县| 廊坊市| 右玉县| 大兴区| 育儿| 弥勒县| 竹山县| 进贤县| 八宿县| 宜宾市| 尉犁县| 贡觉县| 遂昌县| 乌鲁木齐县| 辽中县| 门头沟区| 鄱阳县| 定南县| 孟津县| 西昌市| 黄浦区| 福建省| 迭部县| 正镶白旗| 珲春市| 奉贤区| 固安县| 宜黄县| 龙江县| 泸定县| 鄱阳县| 海兴县| 林周县| 宁武县|