GF Form Editor Help Snippet
public function add_help() {
// only add help to the gf form editor screen
if ($screen = get_current_screen()) {
if ($screen->base == "toplevel_page_gf_edit_forms") {
// get the fields
$fields = TGMembership::get_all_fields();
// only proceed if we have fields
if (count($fields)) {
// help intro
$content = "<p>This is a list of valid field names that if used as parameter names in GF fields will update user data for the user with their username or user id being the content of the hidden GF field <strong>user_id</strong>.</p>";
$content .= "<ul>";
foreach($fields as $name => $field) {
$content .= "<li>$name => {$field['label']} ({$field['type']})</li>";
}
$content .= "</ul>";
// save current help tabs and remove all help tabs, something needed on screens with no pre-existing help
$help_tabs = $screen->get_help_tabs();
$screen->remove_help_tabs();
//TODO: This adds our help to the page (WP_Screen object), but the Help button still doesn't show up. Maybe a bug in GF?
// add our help tab
$screen->add_help_tab( [
'id' => "tgmem_acf_field_gf_editor_help",
'title' => "ACF Fields",
'content' => $content,
]);
// add back any preexsiting help
if (count($help_tabs)) {
foreach ($help_tabs as $help_tab) {
$screen->add_help_tab($help_tab);
}
}
}
}
}
}