Skip to content

Instantly share code, notes, and snippets.

@jaredatch
jaredatch / functions.php
Created May 10, 2017
WPForms smart tags inside checkbox labels
View functions.php
<?php
/**
* Process smart tags inside checkbox choice labels,
*
* @param array $field
* @param array $deprecated
* @param array $form_data
* @return array
*/
function wp_checkbox_choices_process_smarttags( $field, $deprecated, $form_data ) {
@jaredatch
jaredatch / functions.php
Created Mar 16, 2017
WPForms disable multipage scroll
View functions.php
<?php
/**
* Disable multipage scroll
*
*/
function wpf_disable_multipage_scroll() {
?>
<script type="text/javascript">window.wpforms_pageScroll = false;</script>
<?php
}
@jaredatch
jaredatch / functions.php
Created Mar 1, 2017
WPForms conditional form redirects
View functions.php
<?php
/**
* WPForms custom redirect
*
* @param string $url URL form will redirect to
* @param int $form_id Form ID
* @param array $fields Submitted form fields
* @return string
*/
function wpf_custom_redirect( $url, $form_id, $fields ) {
View functions.php
function user_function_restrict_content( $atts, $content = null ) {
if ( is_user_logged_in() && !is_null($content) && !is_feed() ) {
return do_shortcode( $content );
} else {
return 'Sorry, this content is only available for logged users.';
}
}
add_shortcode( 'member', 'user_function_restrict_content' );
@jaredatch
jaredatch / style.css
Created Dec 1, 2016
WPForms letter format
View style.css
.letter-format .wpforms-field {
padding: 0 !important;
display: inline !important;
width: auto !important;
overflow: auto !important;
position: relative !important;
}
.letter-format .wpforms-field-html div {
display: inline !important;
@jaredatch
jaredatch / functions.php
Last active Jan 10, 2022
WPForms display form entries with a custom shortcode
View functions.php
<?php
/**
* Custom shortcode to display WPForms form entries.
*
* Basic usage: [wpforms_entries_table id="FORMID"].
*
* Possible shortcode attributes:
* id (required) Form ID of which to show entries.
* user User ID, or "current" to default to current logged in user.
* fields Comma seperated list of form field IDs.
@jaredatch
jaredatch / functions.php
Created Nov 29, 2016
WPForms Timepicker limit times available
View functions.php
<?php
/**
* WPForms limit times available in the timepicker, hide times that are disabled.
*
*/
function wpf_limit_time_picker() {
?>
<script type="text/javascript">
var wpforms_timepicker = {
scrollDefault: 'now',
View functions.php
<?php
/**
* WPForms automatically add category to posts created with post submission addon.
*
* @param int $post_id Post ID of the new post created
* @param array $fields
* @param array $field_data
* @param int $entry_id
*/
function wpf_post_submissions_add_category( $post_id, $fields, $form_data, $entry_id ) {
@jaredatch
jaredatch / functions-alt.php
Last active Oct 2, 2018
WPForms move field descriptions to top of field
View functions-alt.php
<?php
/**
* Move a single field descriptions to the top of the field, under the label.
*
*/
function wpf_top_field_descriptions() {
?>
<script type="text/javascript">
jQuery(function($){
var $desc = $('#wpforms-1287-field_1-container .wpforms-field-description'),
@jaredatch
jaredatch / functions.php
Created Nov 11, 2016
WPForms remove email notification footer text
View functions.php
<?php
/**
* WPForms remove the "Sent from YOUR SITE" email notification footer text.
*/
add_filter( 'wpforms_email_footer_text', '__return_empty_string' );