WordPress hooks that have been built into the Sign-up Sheets plugin are detailed here. You may find other hooks built within the Sign-up Sheets plugin codebase, but only the ones listed below are expected to be supported now and into the future. Undocumented hooks may be subject to change without notice in future versions.
Modifies the state dropdown array on the sign-up form. By default this array is formatted like…
$states = array(
'AL' => 'Alabama',
'AK' => 'Alaska',
//...
)
Example
The example below adds a new option to the end of the states dropdown field.
add_filter('fdsus_states', 'my_states');
/**
* Filter for states dropdown array
*
* @param string $sql
*
* @return string
*/
function my_states($states)
{
$states['NEW'] = 'My New State';
return $states;
}
Source
File: model/states.php
/**
* Filter for states dropdown array
*
* @param string $sql
*
* @return string
* @since 2.2
*/
return apply_filters('fdsus_states', $states);
Example
The example below shows how you can add an additional check prior to saving the signup to include your own custom form validation before the sign-up is added.
add_filter('fdsus_error_before_add_signup', 'my_error_before_add_signup');
/**
* Do something after a signup is added
*
* @param string $errorMsg
* @param int $taskId
*
* @return string
*/
function my_error_before_add_signup($errorMsg, $taskId)
{
if ($_POST['foo'] !== 'bar') {
$errorMsg = 'Darn, something failed."
}
return $errorMsg;
}
Source
File: controller/scode/sign-up-form.php
/**
* Filter the error check that runs when processing the signup form before the new signup is added
* to the DB
*
* @param string $errorMsg
* @param int $taskId
*
* @return string
*
* @api
* @since 2.2
*/
$errorMsg = apply_filters('fdsus_error_before_add_signup', $errorMsg, $taskId);
Example
The example below shows how you can add code to do something when a new sign-up is added.
add_action('fdsus_after_add_signup', 'my_after_add_signup');
/**
* Do something after a signup is added
*
* @param int $signupId
*/
function my_after_add_signup($signupId)
{
if ($signupId) {
// do something
}
}
Source
File: controller/scode/sign-up-form.php
/**
* Action that runs after the signup is successfully added
*
* @param int $signupId
*
* @api
* @since 2.2
*/
do_action('fdsus_after_add_signup', $signupId);
Example
The example below shows how you can set your own custom success message. This is a simplified example that just returns a string of text, but you are also provided with the default success message $successMsg
along with the $task
and optional $signup
objects to return a more dynamic message as needed.
add_action('fdsus_signup_success_message', 'my_custom_success_msg', 10, 3);
/**
* Set custom success message
*
* @param string $successMsg The content that will be displayed in the notice
* @param TaskModel $task Task object that was signed up for
* @param SignupModel|false $signup Signup object (optional)
*/
function my_custom_success_msg($successMsg, $task, $signup = false)
{
return 'You have signed up. Yay!';
}
Source
File: controller/sheet.php
/**
* Filters the Sign-up Form success notice content.
* May display as one or more on a page depending on how may tasks are signed up for
*
* @param string $successMsg The content that will be displayed in the notice
* @param TaskModel $task Task object that was signed up for
* @param SignupModel|false $signup Signup object (optional)
*
* @api
* @since 2.1.5.3
*/
$successMsg = apply_filters('fdsus_signup_success_message', $successMsg, $task, $signup);