Skip to content

Instantly share code, notes, and snippets.

View dave-mills's full-sized avatar

Dave Mills dave-mills

View GitHub Profile
@dave-mills
dave-mills / example.php
Last active September 28, 2020 08:05
Example Callback function for Ultimate Member dropdown field
function getCities() {
//get the value from the 'parent' field, sent via the AJAX post.
$choice = $_POST['parent_option'];
//Depending on the value of $choice, return a different array.
switch($choice) {
case "France":
$cities = [
"Paris" =>"Paris",
@dave-mills
dave-mills / usermeta-shortcode.php
Last active December 1, 2020 22:02
A WordPress custom shortcode to display a piece of user metadata from the wp_usermeta table. Relies on Ultimate Member plugin
/* Create new shortcode for quickly displaying user metadata.
*** NOTE: This only works if you have the Ultimate Member plugin installed.
*** Use like regular wordpress shortcodes. Enter [USERMETA user_id="*id*" meta="*field_name*"] (replace *id* and *field_name* with actual values)
*** If you use it on an Ultimate Member profile page/tab, it will use the user currently being viewed.
*** On other pages, you must include the "user_id" within the shortcode.
*/
//Add the shortcode to WordPress
add_shortcode('USER_META', 'user_meta_shortcode_handler');
//create the function referenced by the add_shortcode()
@dave-mills
dave-mills / gist:9562745ab5994d614960c86d6ec264b4
Created October 21, 2024 14:37
A proper "renv update" script
#####################################
## This script will install all the packages listed in the renv.lock file.
## It is different to `renv::restore()`, because it will install the latest available versions of each package, rather than the versions that were used when the lockfile was created
##
## This is equivalent to a 'composer update' in php (while renv::restore() is equivalent to 'composer install').
##
## Written because `renv::update()` only updates packages that are currently installed, so is not helpful when the versions specified in a lock file no longer install properly.
#####################################