Commit 0c568944 authored by John James Jacoby's avatar John James Jacoby
Browse files

Signup meta!

parent bb21b289
......@@ -82,6 +82,9 @@ http://github.com/stuttter/wp-user-signups
== Changelog ==
= [3.1.0] - 2017-04-03 =
* Signup meta support
= [3.0.0] - 2017-04-03 =
* Rebrand internally to WP Signups
......
<?php
/**
* Signup Meta Functions
*
* @package Plugins/Signups/Meta/Functions
*/
// Exit if accessed directly
defined( 'ABSPATH' ) || exit;
/**
* Add metadata to a signup.
*
* @since 3.1.0
*
* @param int $id Alias ID.
* @param string $meta_key Metadata name.
* @param mixed $meta_value Metadata value. Must be serializable if non-scalar.
* @param bool $unique Optional. Whether the same key should not be added.
* Default false.
* @return int|false Meta ID on success, false on failure.
*/
function add_signup_meta( $id, $meta_key, $meta_value, $unique = false ) {
return add_metadata( 'signup', $id, $meta_key, $meta_value, $unique );
}
/**
* Remove from a signup, metadata matching key and/or value.
*
* You can match based on the key, or key and value. Removing based on key and
* value, will keep from removing duplicate metadata with the same key. It also
* allows removing all metadata matching key, if needed.
*
* @since 3.1.0
*
* @param int $id Alias ID.
* @param string $meta_key Metadata name.
* @param mixed $meta_value Optional. Metadata value. Must be serializable if
* non-scalar. Default empty.
* @return bool True on success, false on failure.
*/
function delete_signup_meta( $id, $meta_key, $meta_value = '' ) {
return delete_metadata( 'signup', $id, $meta_key, $meta_value );
}
/**
* Retrieve from a signup, metadata value by key.
*
* @since 3.1.0
*
* @param int $id Alias ID.
* @param string $meta_key Optional. The meta key to retrieve. By default, returns
* data for all keys. Default empty.
* @param bool $single Optional. Whether to return a single value. Default false.
* @return mixed Will be an array if $single is false. Will be value of meta data
* field if $single is true.
*/
function get_signup_meta( $id, $meta_key = '', $single = false ) {
return get_metadata( 'signup', $id, $meta_key, $single );
}
/**
* Update metadata for a signup ID, and/or key, and/or value.
*
* Use the $prev_value parameter to differentiate between meta fields with the
* same key and signup ID.
*
* If the meta field for the signup does not exist, it will be added.
*
* @since 3.1.0
*
* @param int $id Alias ID.
* @param string $meta_key Metadata key.
* @param mixed $meta_value Metadata value. Must be serializable if non-scalar.
* @param mixed $prev_value Optional. Previous value to check before removing.
* Default empty.
* @return int|bool Meta ID if the key didn't exist, true on successful update,
* false on failure.
*/
function update_signup_meta( $id, $meta_key, $meta_value, $prev_value = '' ) {
return update_metadata( 'signup', $id, $meta_key, $meta_value, $prev_value );
}
......@@ -8,7 +8,7 @@
* License: GPLv2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Description: Signup management for WordPress
* Version: 3.0.0
* Version: 3.1.0
* Text Domain: wp-signups
* Domain Path: /wp-user-signups/assets/languages/
*/
......@@ -47,6 +47,7 @@ function _wp_signups() {
require_once $plugin_path . 'includes/functions/cache.php';
require_once $plugin_path . 'includes/functions/common.php';
require_once $plugin_path . 'includes/functions/capabilities.php';
require_once $plugin_path . 'includes/functions/metadata.php';
require_once $plugin_path . 'includes/functions/hooks.php';
// Tables
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment