• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Tips and Tricks HQ

  • Home
  • Blog
  • Projects
    • All Projects
    • Simple WP Shopping Cart
    • WP Security and Firewall Plugin
    • WP Download Monitor
    • WP eStore Plugin
    • WP Affiliate Platform
    • WP eMember
    • WP PDF Stamper
    • WP Lightbox Ultimate
    • WP Photo Seller
  • Products
    • All Products
    • Checkout
  • Support
    • Support Portal
    • Customer Only Forum
    • WP eStore Documentation
    • WP Affiliate Software Documentation
    • WP eMember Documentation
  • Contact

Adding Your Own Custom Fields in the Software License Manager Plugin

You are here: Home / Web Development / Adding Your Own Custom Fields in the Software License Manager Plugin

Last updated: December 14, 2016




This is a tutorial for the Software License Manger plugin. This tutorial is aimed at advanced WordPress Plugin developers.

Lets say, you want to create an extension or a custom plugin to add couple of extra fields to save some info with each of the license keys. Below is a guideline on how to do it.



Decide Where You Will Save the Data

You need to first decide where this extra data will be saved. There are 3 choices:

1) Alter the License Key Table

When your custom plugin/extension is activated, you would alter the core plugin’s license key database table (wp_lic_key_tbl) and add the new columns.

2) Create Your Own Custom Table

You can create your own custom database table to store the values. Each license key has a unique ID that identifies the key in the license keys table of the core plugin. In your new table, you need to have a column to store that unique ID of the license key. That will allow you to connect each row of your table to a license key.

3) Use Custom Post Types

You can also create your own Custom Post Types and store the custom values there.

The key element to understand is that you need to use the unique ID of the keys to connect your custom data to a license key.

Show the Fields in the Add/Edit Licenses Interface

The following filter can be used to add the HTML code for your custom fields. This filter is triggered by the core plugin just above the “Save Record” button.

slm_add_edit_interface_above_submit

Code Example:

add_filter('slm_add_edit_interface_above_submit', 'my_custom_output', 10, 2);
function my_custom_output($output, $data){
    $row_id = $data['row_id'];
    $key = $data['key'];
    //TODO - query to retrieve your extra data so you can create the HTML output here.
    $output .= 'My Custom Field: <input type="text" name="my_test_field" value="...." />';

    return $output;
}

Save the Custom Data When a License Key is Saved

You can use any of the following two action hooks to listen for the form submission then read the values from the REQUEST parameter and save the custom data.

slm_add_edit_interface_save_submission

or

slm_add_edit_interface_save_record_processed

Code Example:

add_action('slm_add_edit_interface_save_record_processed', 'save_my_custom_data');
function save_my_custom_data($data){
    $row_id = $data['row_id'];
    $key = $data['key'];
    //TODO - read your custom data from the REQUEST parameter and save it.
}

That should do it. Your custom plugin/extension can now add, edit and show extra custom fields for each license key.

Related Posts

  • Upgrading the Core WordPress Custom Menu Widget
  • WordPress Plugin – Cite the Source for Images Attached to Your WordPress Posts
  • WordPress Action Hooks and Filter Hooks – An Introduction
  • Hiding the Download URL of the File with Simple Download Monitor Plugin

Web Development,  Wordpress Plugin Code example,  plugin,  wordpress developer tutorial,  Wordpress Plugin,  WordPress tutorial,  WordPress Tweaks

Reader Interactions

Comments (2 responses)

  1. admin says:
    December 14, 2016 at 8:32 pm

    @Michel, Thank you. I have corrected it.

  2. Michel Velis says:
    December 14, 2016 at 2:26 pm

    there is a syntax error on:

    add_filter(‘slm_add_edit_interface_above_submit, ‘my_custom_output’, 10, 2);

    missing ‘ after slm_add_edit_interface_above_submit. should be

    add_filter(‘slm_add_edit_interface_above_submit’, ‘my_custom_output’, 10, 2);

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Featured & Popular Articles

Video Answers to Top WordPress QuestionsWordPress Optimization Tips and Tricks for Better Performance and SpeedEssential WordPress Security Tips - Is Your Blog Protected?WordPress Simple PayPal Shopping Cart PluginTop 15 Search Engine Optimization (SEO) Techniques I Forget to DoList of the Best and Must Use WordPress PluginsHow do I Start a Blog and Make Money Online?Good Domain Name Picking Tips for Your Blog SetupFind Out Which WordPress Web Hosting Company Offers the Cheapest and Reliable Web Hosting Solution

Featured WordPress Plugins

wordpress estore plugin
wordpress membership plugin
WordPress PDF Stamper Plugin
WordPress Lightbox Ultimate Plugin
WordPress photo seller plugin
wordpress affiliate plugin

Recent Posts

  • PayPal's Pay in 4 Feature [...]
  • Add a WordPress Admin User Account via PHP [...]
  • Enabling Two-Factor Authentication (2FA) for a PayPal Acco [...]
  • PayPal Test Cards (Sandbox Testing) [...]
  • How to Make a Stripe Text Link Payment Button [...]

Comment & Socialize

  • Saved my day. Thanks mate. ...
    - H109
  • Thank you very much! ...
    - Nataliya
  • Thank you for quickly answe ...
    - Alain
  • @Robin, Looks like the pric ...
    - admin
  • @Dave, Try the following in ...
    - admin

Check out our solutions

View our WordPress plugin collection and start using them on your site.

Our WordPress Solutions

Footer

Company

  • About
  • Privacy Policy
  • Terms and Conditions
  • Affiliate Program
  • Affiliate Login

Top WordPress Plugins

  • Simple Shopping Cart
  • PayPal Donations
  • All in One WP Security
  • WP eStore
  • WP eMember

Blogging Tips

  • How to Start a Blog
  • Selecting a Good Domain
  • Cheap WP Hosting
  • WP Video Tutorials
  • Simple SEO Tips

Search


Keep In Touch

Copyright © 2021 | Tips and Tricks HQ