Skip to content

Instantly share code, notes, and snippets.

@khaledsaikat
Created July 29, 2016 09:50
Show Gist options
  • Save khaledsaikat/b8be09b7f837fff7f0e0491d5827ef0f to your computer and use it in GitHub Desktop.
Save khaledsaikat/b8be09b7f837fff7f0e0491d5827ef0f to your computer and use it in GitHub Desktop.
Replace label and input order
add_filter('user_meta_field_display', function ($html) {
// Get label html
preg_match("/<label.*>.*<\/label>/", $html, $matches);
$label = $matches[0];
// Get input html
preg_match("/<input.*\/>/", $html, $matches);
$input = $matches[0];
// Create new html
$newHtml = "<div>{$input}{$label}</div>";
// Replace with pattern
$html = preg_replace("/<label.*>.*<\/label><input.*\/>/", $newHtml, $html);
return $html;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment