Skip to content

Instantly share code, notes, and snippets.

View Twanneman's full-sized avatar

Twanneman Twanneman

View GitHub Profile
<?php
// SEND ACCESS LEVEL TO GRAVITY FORMS
function get_access_level(){
global $user_ID;
$plan_id = rcp_get_subscription_id( $user_ID );
$access_level = rcp_get_subscription_access_level( $plan_id );
return $access_level;
}
@spigists
spigists / new_gist_file.css
Created October 2, 2013 16:16
Bootstrap 3 styles for Gravity Forms, make sure that in Forms > Settings you have Output CSS set to No and Output HTML5 set to Yes
.gform_wrapper ul {
padding-left: 0;
list-style: none; }
.gform_wrapper li {
margin-bottom: 15px; }
.gform_wrapper form {
margin-bottom: 0; }
@spivurno
spivurno / gw-gravity-forms-map-fields-to-field.php
Last active May 22, 2023 17:27
Gravity Wiz // Gravity Forms // Map Submitted Field Values to Another Field
<?php
/**
* Gravity Wiz // Gravity Forms // Map Submitted Field Values to Another Field
*
* Usage
*
* 1 - Enable "Allow field to be populated dynamically" option on field which should be populated.
* 2 - In the "Parameter Name" input, enter the merge tag (or merge tags) of the field whose value whould be populated into this field.
*
* Basic Fields
@madalinignisca
madalinignisca / gravityforms.css
Last active November 14, 2019 02:30
Gravity forms default styles and built in classes that can be used when creating forms with this plugin Maintained from http://www.gravityhelp.com/documentation/page/Design_and_Layout Use it to style Gravity Forms like a boss :)
/****************************************************************************
*** Gravity styles ***
****************************************************************************/
/*Form Body
contains the main form content*/
body .gform_wrapper .gform_body {border: 1px solid red}
/*Form List Container
unordered list used to structure all of the form elements*/
@CMCDragonkai
CMCDragonkai / wp-config.php
Last active November 5, 2017 03:30
Wordpress: Automatic Url and Content Dir/Url Detection for Wordpress Composer Installs. Add to the top of the wp-config.php script.
<?php
/**
* Automatic Url + Content Dir/Url Detection for Wordpress
*/
$document_root = rtrim(str_replace(array('/', '\\'), '/', $_SERVER['DOCUMENT_ROOT']), '/');
$root_dir = str_replace(array('/', '\\'), '/', __DIR__);
$wp_dir = str_replace(array('/', '\\'), '/', __DIR__ . '/wp');
$wp_content_dir = str_replace(array('/', '\\'), '/', __DIR__ . '/wp-content');
@nikolov-tmw
nikolov-tmw / multiple-roles-per-user.php
Last active September 5, 2024 01:45
Multiple roles per user WordPress plugin.
<?php
/**
* Plugin Name: Multiple Roles per User
* Description: Allows anyone who can edit users to set multiple roles per user. In a default WordPress environment that wouldn't have much of an effect, since the user would have the privileges of the top-privileged role that you assign to him. But if you have custom roles with custom privileges, this might be helpful.
* Version: 1
* Author: nikolov.tmw
* Author URI: http://paiyakdev.com/
* License: GPL2
*/
/*
@iandunn
iandunn / programmatic_login.php
Last active March 7, 2023 18:18
Programmatically log in a WordPress user
/**
* Programmatically logs a user in
*
* @param string $username
* @return bool True if the login was successful; false if it wasn't
*/
function programmatic_login( $username ) {
if ( is_user_logged_in() ) {
wp_logout();
@tmoitie
tmoitie / gist:9808555
Last active November 15, 2024 15:56
Wordpress: Gravity Forms List to ACF Repeater post save
<?php
add_action('gform_after_submission', 'gfToAcfListToRepeater', 10, 2);
function gfToAcfListToRepeater($entry, $form)
{
foreach ($form['fields'] as $field) {
if (!($field['type'] == 'post_custom_field' && $field['inputType'] == 'list' && $field['enableColumns'] == true)) {
continue;
}
$id = $field['id'];
@1shiharat
1shiharat / acf-repeater-image-convert-thumbnail.php
Created March 28, 2014 04:40
acf-repeater-image-convert-thumbnail
/**
* ACF
* リピーターリピーターフィールドでの一番はじめの画像をアイキャッチ画像にも設定する。
**/
function acf_set_featured_image( $value, $post_id, $field ){
if( $value != ''){
update_post_meta($post_id, '_thumbnail_id', $value);
} else {
delete_post_meta($post_id, '_thumbnail_id');
@imknight
imknight / gravity-form-save-acf
Last active November 22, 2017 21:29
WordPress Gravity Form Save Custom Meta Field for Advanced Custom Fields
add_action("gform_after_submission_1", "acf_post_submission", 10, 2);
function acf_post_submission ($entry, $form)
{
$post_id = $entry["post_id"];
update_field('address1', $entry['29.1'], $post_id);
update_field('address2', $entry['29.2'], $post_id);
update_field('address3', $entry['29.3'], $post_id);
}