[oik] plugins.com

WordPress plugins and themes

  • Home
  • About
    • lazy shortcodes
    • smart shortcodes
    • oik base plugin
      • oik – donate
      • oik PayPal buttons
      • oik installation
      • oik Button Shortcode button
      • oik changelog
      • oik FAQ
      • oik plugins on SVN
      • oik plugins on GitHub
  • Plugins
    • oik base plugin
    • FREE oik plugins
    • WordPress plugins
    • Premium oik plugins
    • Bespoke oik plugins
  • Shortcodes
    • Shortcode examples
  • Blocks
    • Block examples
  • APIs
    • ALL action and filter hooks
  • Blog

oiksp_validate_name() – Return a validated name field

Description

Return a validated name field

At the start of coding this all we wanted to do was to not accept a name starting with a digit e.g. 532ff6123 Because, except for names in non Latin languages, it should really be a letter. So I looked at stack overflow and found this, which seems like as good a start as any http://stackoverflow.com/questions/888838/regular-expression-for-validating-names-and-surnames Trying this Regular expression ^[\p{L} \.'\-]+$ But in the 'complete tested solution' it's ^[\p{L}\p{M}' \.\-]+$ And perhaps we need to convert apostrophes to ' Apostrophes are dealt with by stripping slashes from the input value before performing the preg_match. Later, if the field is redisplayed, then we run stripslashes again.

Usage

$string|null = oiksp_validate_name();

Parameters

Returns

string|null the name field if validated

Source

File name: oik-squeeze/shortcodes/oik-squeeze.php
Lines:
1 to 26 of 26
function oiksp_validate_name() {
  $name = bw_array_get( $_REQUEST, "oiksp_name", null );
  $name = trim( $name );
  $name_for_match = stripslashes( $name );
  $matched = preg_match("/^[\p{L} \.'\-]+$/", $name_for_match, $output_array);
  //bw_trace2( $output_array, "output array for name:$name:" );
  //bw_trace2( $matched, "matched", false );
  if ( !$matched ) {
    $_REQUEST['oiksp_name'] = $name;
    $name = null;

  }

  
/**
 * Don't process requests where the Name is more than 5 words.
 * This is just spam.
 * Note: The user doesn't get any message when the form is redisplayed.
 */
  $words = explode( ' ', $name);
  if ( count( $words ) >= 5 ) {
    bw_trace2( $name, 'Name considered to be spam: ', false);
    $_REQUEST['oiksp_name'] = '';
    $name = null;
  }
  return( $name );
}
 
 View on GitHub

Called by

1 to 1 of 1
  • oiksp_validate_fields() – Validate the fields on the form

Invoked by

    Calls

    1 to 1 of 1
    • bw_array_get() – Return the array[index] or array->index (for an object) or a default value if not set

    Call hooks

    Function name: oiksp_validate_name
    Plugin ref: oik-squeeze
    Version: 1.2.1
    Sourcefile: shortcodes/oik-squeeze.php
    File ref: shortcodes/oik-squeeze.php
    Deprecated?: No
    API Letters: N,O,V

    Published: March 31, 2017 | Last updated: March 31, 2017

    Information

    Function name: oiksp_validate_name
    Plugin ref: oik-squeeze
    Version: 1.2.1
    Sourcefile: shortcodes/oik-squeeze.php
    File ref: shortcodes/oik-squeeze.php
    Deprecated?: No
    API Letters: N,O,V

    Recent plugin updates

    oik-weight-zone-shipping v0.2.13 oik-weight-zone-shipping v0.2.13 has been tested with WooCommerce 10.1.2 and WordPress 6.8.2 ...
    SB Children Block v1.3.0 Upgrade to SB Children Block v1.3.0 for support for PHP 8.3 and PHP 8.4  ...
    oik v4.15.3 Update to oik v4.15.3 for a couple of security fixes. Tested with WordPress 6.8.2 ...
    oik-privacy-policy v1.4.9 Update to oik-privacy-policy v1.4.9 for a security fix. Tested with WordPress 6.8.2 and PHP 8.3 and PHP 8.4 ...
    oik-nivo-slider v1.17.0 oik-nivo-slider v1.17.0 introduces the Nivo slider block - oik-nivo-slider/nivo. ...

    Plugins

    • All Plugins
    • oik base plugin
    • FREE oik plugins
    • WordPress plugins
    • Premium oik plugins

    Themes

    • FREE themes
    • Bespoke themes
    • Premium themes

    Blocks

    • All Blocks
    • Block examples
    • About Blocks

    Shortcodes

    • All Shortcodes
    • Shortcode examples
    • About Shortcodes

    Reference

    • About APIs
    • All APIs
    • All Classes
    • All Files
    • All Hooks

    Support

    • Contact
    • Cookies policy
    • Get API key
    • Privacy
    • Request support
    • Sitemap
    • Stay informed
    • Terms and Conditions
    oik-plugins
    Email: herb@bobbingwide.com

    Weight shipping plugins

    Find out which cart weight shipping plugin you need for your WooCommerce site.
    Which cart weight based plugin do I need?

    Site:  www.oik-plugins.com
    © Copyright oik-plugins 2011-2025. All rights reserved.


    Website designed and developed by Herb Miller of Bobbing Wide
    Proudly powered by WordPress and oik-plugins

    WordPress version: 6.8.3

    Gutenberg version: 21.7.0

    PHP version: 8.2.29