Created
July 24, 2015 16:55
-
-
Save zackkatz/80d54ab82b1aee548b08 to your computer and use it in GitHub Desktop.
GravityView - Show contact form when there are no entries in a View
This file contains hidden or 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
<?php | |
add_filter( 'gravitview_no_entries_text', 'add_form_to_gravitview_no_entries_text', 10, 2 ); | |
/** | |
* Modify the text displayed when there are no entries to show a Gravity Forms form | |
* | |
* @param string $output The existing "No Entries" text | |
* @param boolean $is_search Is the current page a search result, or just a multiple entries screen? | |
*/ | |
function add_form_to_gravitview_no_entries_text( $text, $is_search = false ) { | |
// If it's a search and there are no entries, it's none of our concern. | |
if( $is_search ) { return $text; } | |
// UPDATE ME!!! | |
// Modify the Gravity Forms shortcode below with the correct form ID | |
$form = do_shortcode('[gravityform id="2"]'); | |
// UPDATE ME!!! | |
// Modify the text below as well | |
$text = 'You have no entries yet. Use the form below to create an entry.'; | |
// Return both the text and the form | |
return $text . $form; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment