Skip to content

Instantly share code, notes, and snippets.

View gicolek's full-sized avatar

Rafał Gicgier - Certified Codeable Expert Developer gicolek

View GitHub Profile
@gicolek
gicolek / gf_validate_register.php
Created October 7, 2014 08:47
This hooks validates the Gravity Forms form submissions checking if the user, has already been registered in the database.
<?php
// remember, the hook suffix, should contain the form id!
add_filter( "gform_field_validation_3", 'gf_custom_validation', 10, 4 );
/**
* Custom GF validation function used for pagination and required fields
*
* @return string
*/
@gicolek
gicolek / gf_register.php
Last active June 27, 2024 11:30
A sample code, which fires before the form was submitted and creates a new user account.
<?php
// remember - the suffix of the hook should contain specific form id!
add_action( "gform_pre_submission_3", "wp_doin_pre_submission" );
function wp_doin_pre_submission($form) {
// get the values entered by the user during the form submission
// note: the input_{number} may be different in your case, make sure to double check the id of your field
// and swap it if needed
<?php
// the _3 prefix has to match the id of the form you have created
add_filter( "gform_field_validation_3", "login_validate_field", 10, 4 );
function login_validate_field($result, $value, $form, $field) {
// make sure this variable is global
// this function is fired via recurrence for each field, s
global $user;
<?php
// the _3 prefix has to match the id of the form you have created
add_action( "gform_after_submission_3", "login_form_after_submission", 10, 2 );
function login_form_after_submission($entry, $form) {
// get the username and pass
$username = $entry[1];
$pass = $entry[2];
@gicolek
gicolek / do_action.php
Last active September 2, 2017 16:27
Do Action explained
<?php
// this can be placed anywhere in the plugin (before storing the form values in the database)
// $form_data could be an array of data which was created by the user
do_action('my_action_after_save', $form_data);
// we're telling wordpress to execute the code added in the second parameter method right where do_action has been specified
add_action('my_action_after_save', 'my_action_after_save_hook', 10);
/**
@gicolek
gicolek / a.php
Created August 4, 2014 16:07
sample
<h1>Sample WordPress Page</h1>
<div class="entry-content">
<h2>Heading 2</h2>
<p>Lorem ipsum dolor sit amet, <a href="http://www.example.org">consectetuer adipiscing</a> elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud <strong>exerci tation</strong> ullamcorper
suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
<p>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse <em>molestie consequat</em>, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio <abbr title="dignissim qui blandit">dqb</abbr> praesent luptatum zzril
delenit augue duis dolore te feugait nulla facilisi.</p>
<?php
require_once(__DIR__ . '/class-like-saveit-db-installer.php');
class Like_Saveit_Db extends Like_Saveit_DB_Installer {
/**
* Members Table Name
*/
protected static $m_tbl_name = 'tbl_Member_Master';
@gicolek
gicolek / ls.php
Created July 28, 2014 09:09
LikeSaveIt
<?php
require_once(__DIR__ . '/includes/class-like-saveit-db.php');
require_once(__DIR__ . '/includes/class-session-db.php');
/**
* Plugin Name.
*
* @package Plugin_Name
* @author Your Name <[email protected]>
* @license GPL-2.0+
* @link http://example.com
@gicolek
gicolek / db_session.php
Created July 28, 2014 09:08
DB Session Storage
<?php
/**
* Simple Class which overwrites the session storage
*/
class Like_Saveit_Session_Handler {
/**
* Store the db
* @var object
@gicolek
gicolek / trigger_view.php
Created April 22, 2014 12:13
Trigger View
<script>
function trigger_view(id) {
jQuery.post(
<?php echo json_encode( 'some_url' ) ?>,
{
// a post id, fetched before
"cp_post_id": id,
// wordpress nonce for safety reason
"nonce": '<?php echo wp_create_nonce( 'view' ); ?>'
}