Skip to content

Instantly share code, notes, and snippets.

@hellofromtonya
Created May 19, 2015 00:53
Show Gist options
  • Save hellofromtonya/45bf9c99e87fb51d7af1 to your computer and use it in GitHub Desktop.
Save hellofromtonya/45bf9c99e87fb51d7af1 to your computer and use it in GitHub Desktop.
WordPress Challenge for May 18, 2015
<?php
/**
* As part of our weekly challenges, take a crack at this one.
* To play along,
* 1. Copy the code into a Gist,
* 2. Answer each of the questions by supplying the code;
* 3. Provide some notes as to your train of thought;
* 4. Then submit the gist's URL for us to review.
*
* We'll respond back and make comments in your gist.
* Happy Coding </>
* Tonya @hellofromtonya
*/
function foo( $user_id ) {
// Q1 How can I get the arguments pass when foo is called?
// Q2 How can I get a count of the number arguments passed into foo?
// Q3 How would you sanitize the meta value, if it is present?
if ( $meta_value && $meta_key ) {
update_user_meta( $user_id, $meta_key, $meta_value );
}
}
$user_id = 1;
$meta_key = 'some_meta_key';
$meta_value = 'bar';
foo( $user_id, $meta_key, $meta_value );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment