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 / wp_cli_site_setup
Created January 25, 2015 23:30
Quick site setup WP-CLI
cd d:
cd xampp
cd htdocs
mkdir test_site
cd test_site
git clone git_repo_url.git
wp core download --allow-root
wp core config --dbname="test" --dbuser=wp --dbpass=wp --dbhost="localhost" --allow-root
wp core install --url=test.dev --title="test - A WordPress Site" --admin_user=admin --admin_password=password [email protected] --allow-root
@gicolek
gicolek / wp_cli
Created January 25, 2015 22:53
WP-CLI list users
wp user list
@gicolek
gicolek / gf_validate_edit_account.php
Last active June 27, 2024 12:23
GF Validate Field Hook for
<?php
// change the number suffix to the one corresponding to your form and field's id!
add_filter( 'gform_field_validation_1_1', 'wp_doin_validate_password_field', 10, 4 );
/**
* @hook gform_field_validation_4
*
* This function is assigned to the old password field, and then iterates over all form fields
* if it hits a field with the pass-confirm class assigned it then compares it's value
@gicolek
gicolek / gf_pre_submission_edit_acc.php
Last active June 27, 2024 12:21
Gravity Forms Pre Submission Hook for
<?php
// make sure to change 5he prefix to the one you are using with your forms
add_action( "gform_pre_submission_4", "wp_doin_edit_pre_submission" );
/**
* @hook gform_pre_submission_4
*/
function wp_doin_edit_pre_submission( $form ) {
@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>