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

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.

主站蜘蛛池模板: 岳西县| 洮南市| 景德镇市| 清镇市| 洛浦县| 竹溪县| 藁城市| 峡江县| 闽侯县| 视频| 临泽县| 临江市| 吴川市| 南开区| 大方县| 新绛县| 石狮市| 淮阳县| 永胜县| 蒲江县| 泾源县| 论坛| 佳木斯市| 东平县| 赣州市| 陇南市| 屏山县| 义马市| 新密市| 凉城县| 江城| 南溪县| 连江县| 饶阳县| 平武县| 明光市| 阳山县| 桃源县| 天长市| 六枝特区| 丽水市|