[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

You appear to be a bot. Output may be restricted

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 );
}
 

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

Information

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

Recent plugin updates

oik v4.7.2 oik v4.7.2 includes a fix to the logic to render blocks for Content and Excerpts in the bw_pages shortcode. ...
oik v4.7.1 Upgrade to oik v4.7.1 for bw_pages rendering blocks for Content and Excerpts, and support for post_name attribute for shortcode which query posts ...
oik-shortcodes v1.41.1 Upgrade to oik-shortcodes v1.41.1 for a couple of minor changes. ...
oik-bob-bing-wide v2.2.2 Upgrade to oik-bob-bing-wide v2.2.2 for improvements to bw_dash examples and fixes to some SVG icon's visibility. ...
oik-bwtrace v3.3.1 Upgrade to oik-bwtrace v3.3.1 to measure plugin load times and ad hoc action timing points. ...

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: [email protected]

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-2022. All rights reserved.


Website designed and developed by Herb Miller of Bobbing Wide
Proudly powered by WordPress and oik-plugins
WordPress 6.0.1. PHP: 7.4.30. Memory limit: 768M