Skip to content

Instantly share code, notes, and snippets.

@wkw
wkw / gravity-form.php
Last active November 16, 2020 02:23 — forked from OutThisLife/gravity-form.php
Custom: Gravity Forms WP API Submission and GF API form entry creation plus send notifications
<?php
/**
* Add WP API endpoint for form submission, then create new
* Gravity Forms entry and send notifications.
*/
// rest api endpoint for forms submission
add_action( 'rest_api_init', function () {
register_rest_route( 'ahr/v1', '/forms', array(
'methods' => 'POST',
@srikat
srikat / functions.php
Created August 19, 2016 06:18
Change skiplinks heading tag from h2 to h1 in Genesis
remove_action ( 'genesis_before_header', 'genesis_skip_links', 5 );
add_action ( 'genesis_before_header', 'sk_skip_links', 5 );
/**
* Add skiplinks for screen readers and keyboard navigation
*
* @since 2.2.0
*/
function sk_skip_links() {
if ( ! genesis_a11y( 'skip-links' ) ) {
@lukecav
lukecav / functions.php
Created August 17, 2016 16:24
Change the currency symbol from '$' to 'USD' in Woocommerce
add_filter( 'woocommerce_currency_symbol', 'change_currency_symbol', 10, 2 );
function change_currency_symbol( $symbols, $currency ) {
if ( 'USD' === $currency ) {
return 'USD';
}
if ( 'EUR' === $currency ) {
return 'Euro';
}
@wpscholar
wpscholar / create-admin-user.php
Last active January 30, 2025 17:31
Create a new admin user in WordPress via code. Drop this file in the mu-plugins directory and update the variables, then load a page in WordPress to create the user. Remove the file when done.
<?php
add_action( 'init', function () {
$username = 'admin';
$password = 'password';
$email_address = 'webmaster@mydomain.com';
if ( ! username_exists( $username ) ) {
$user_id = wp_create_user( $username, $password, $email_address );
@vishalbasnet23
vishalbasnet23 / Readme.txt
Created December 15, 2014 11:20
Custom Activation Link on Sign Up WordPress
Step by step guide.
First Phase:
1.First create a html form with first name, last name and email field for signing up process.( Remember the action of the form it has to be the page slug of email confirmation page that you will be creating at in next phase. )
Second Phase :
1.Create a Page ( Remember the slug has to be the same of that of action of the form of phase one ) and assign the template template-confirmation-mail.php
2.This page is responsible for generating unqiue hash key and sending that hash key along with the user's new account credentials to their email.
3.Remember the link of the activation_link has to the link to the email-verification template, which we will be creating in next phase.
Third Phase :
1. Create a page and assign it to Email Verification Template.( Remember this template has to be assigned to the page that you sent in the mail in previous step )
2. This page is responsilble matching that unqiue key sent on the email once new user visit that page.
@keithdevon
keithdevon / manual-gravity-forms
Created September 25, 2014 21:05
Manually create entries and send notifications with Gravity Forms
<?php
// Manually create entries and send notifications with Gravity Forms
$form_id = 10;
// add entry
$entry = array(
"form_id" => $form_id,
"1" => "Entry for field ID 1",
@thagxt
thagxt / Get Author's name outside Loop in WordPress.php
Last active May 22, 2021 12:28
Get Author's name outside Loop in WordPress
<?php
global $post;
$author_id=$post->post_author;
?>
<?php
/* You can also use one of these instead:
- nickname
- user_nicename
- display_name
@thejamescollins
thejamescollins / functions.php
Last active August 5, 2025 09:38
Display product description on WooCommerce shop/category pages
<?php
/**
* Add the product's short description (excerpt) to the WooCommerce shop/category pages. The description displays after the product's name, but before the product's price.
*
* Ref: https://gist.github.com/om4james/9883140
*
* Put this snippet into a child theme's functions.php file
*/
function woocommerce_after_shop_loop_item_title_short_description() {
global $product;
@ajithrn
ajithrn / custom-taxonomy-list.php
Last active June 14, 2019 13:08
Wordpress: list custom taxonomy
<?php
/**
* list taxonomy accoeding to the custom post type
* @var [string]
* ref: http://codex.wordpress.org/Template_Tags/wp_list_categories
*/
$custom_taxonomy = get_object_taxonomies('taxonomy-slud-or-id');
if(count($custom_taxonomy) > 0):
@mommaroodles
mommaroodles / functions.php
Created February 2, 2014 00:16
Woocommerce: Remove Company Input Field in Checkout Page
<?php
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
unset($fields['billing']['billing_company']);
return $fields;
}
?>