Last active
July 11, 2018 01:36
-
-
Save mrtechnique/7f2109d4a8d9fb1aa17877871ecb512d to your computer and use it in GitHub Desktop.
Generating WordPress Shortcodes from URL Parameters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//1. CAPTURE FIRST NAME FROM URL | |
function aa_first_name() { | |
$aa_first_name = $_GET["fname"]; | |
if (isset($aa_first_name)) { | |
$aa_first_name = ucfirst($aa_first_name); | |
return $aa_first_name; | |
} else { | |
return ''; | |
} | |
} | |
add_shortcode('first-name', 'aa_first_name'); | |
//2. CAPTURE LAST NAME FROM URL | |
function aa_last_name() { | |
$aa_last_name = $_GET["lname"]; | |
if (isset($aa_last_name)) { | |
$aa_last_name = ucfirst($aa_last_name); | |
return $aa_last_name; | |
} else { | |
return ''; | |
} | |
} | |
add_shortcode('last-name', 'aa_last_name'); | |
//3. CAPTURE EMAIL FROM URL | |
function aa_email() { | |
$aa_email = $_GET["email"]; | |
if (isset($aa_email)) { | |
return $aa_email; | |
} else { | |
return ''; | |
} | |
} | |
add_shortcode('email', 'aa_email'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment