Skip to content

Instantly share code, notes, and snippets.

@jaredatch
jaredatch / functions.php
Created May 10, 2017 19:25
WPForms smart tags inside checkbox labels
<?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 March 16, 2017 14:31
WPForms disable multipage scroll
<?php
/**
* Disable multipage scroll
*
*/
function wpf_disable_multipage_scroll() {
?>
<script type="text/javascript">window.wpforms_pageScroll = false;</script>
<?php
}
@jaredatch
jaredatch / functions.php
Created March 1, 2017 16:59
WPForms conditional form redirects
<?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 ) {
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 December 1, 2016 19:13
WPForms letter format
.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 October 16, 2023 11:51
WPForms display form entries with a custom shortcode
<?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 November 29, 2016 20:07
WPForms Timepicker limit times available
<?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',
@jaredatch
jaredatch / functions.php
Created November 26, 2016 04:07
WPForms
<?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 October 2, 2018 14:24
WPForms move field descriptions to top of field
<?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 November 11, 2016 16:31
WPForms remove email notification footer text
<?php
/**
* WPForms remove the "Sent from YOUR SITE" email notification footer text.
*/
add_filter( 'wpforms_email_footer_text', '__return_empty_string' );