Skip to content

Instantly share code, notes, and snippets.

View DarrylErentzen's full-sized avatar

Darryl Erentzen DarrylErentzen

View GitHub Profile
@DarrylErentzen
DarrylErentzen / gist:9652556
Created March 19, 2014 22:12
get ID of post created by Formidable Pro "Create Posts" using 'frm_after_create_entry' hook
function process_form($entry_id, $form_id) {
global $frmdb, $wpdb;
$created_post_id = $wpdb->get_var("SELECT post_id FROM $frmdb->entries WHERE id=".$entry_id."");
// whatever else this function is supposed to do
}
add_action('frm_after_create_entry', 'process_form', 50, 2);
// low priority to ensure that the post has actually been created - careful not to fire too soon
@DarrylErentzen
DarrylErentzen / gist:9553046
Created March 14, 2014 17:51
reference current post/page outside of loop in wordpress
$page_id = $wp_query->post->id; // using global var to reference current post/page outside of loop in wordpress
@DarrylErentzen
DarrylErentzen / gist:9277980
Created February 28, 2014 19:29
createFormControl
/**
* Helper-function outputs the correct form element (input tag, select tag, checkbox tag) for the given item
* @param $aOptionKey string name of the option (un-prefixed)
* @param $aOptionMeta mixed meta-data for $aOptionKey (either a string display-name or an array(display-name, option1, option2, ...)
* @param $savedOptionValue string current value for $aOptionKey
* @return void
*/
protected function createFormControl($aOptionKey, $aOptionMeta, $savedOptionValue, $aOptionFormat = 'select') {
if (is_array($aOptionMeta) && count($aOptionMeta) >= 2) {