Skip to content

Instantly share code, notes, and snippets.

View adriannees's full-sized avatar

Adrianne adriannees

View GitHub Profile
@adriannees
adriannees / elementor-registration-form.php
Last active September 11, 2023 11:04
Elementor Pro Form - New User Registration
// Add this to a code snippet via the Code Snippets plugin (modified from (from https://alfatahnesab.com/how-to-create-elementor-user-registration-form/)
// This is the hooks of elementor form after form submit (from https://alfatahnesab.com/how-to-create-elementor-user-registration-form/)
add_action( 'elementor_pro/forms/new_record', 'alfa_elementor_form_create_new_user' , 10, 2 );
function alfa_elementor_form_create_new_user($record,$ajax_handler) // creating function
{
$form_name = $record->get_form_settings('form_name');
//Check that the form is the "Create New Subscriber" or "Create New Editor" (or whichever form names you want) if not - stop and return;
@adriannees
adriannees / elementor_email_validation.php
Last active January 2, 2021 23:50
Elementor Form Email Validation
// Validate confirmation email ref (https://github.com/elementor/elementor/issues/8684)
add_action( 'elementor_pro/forms/validation', function ( $record, $ajax_handler ) {
// Create variables representing the field ids of the fields
$first_email_field = $record->get_field( ['id' => 'email'] ); // Field ID (Advanced tab) is "email"
$second_email_field = $record->get_field( ['id' => 'email_confirm'] ); // Field ID (Advanced tab) is "email_confirm"
if ( property_exists( $second_email_field ) ) {
@adriannees
adriannees / welcome-message.php
Last active July 16, 2020 00:16
Add custom shortcode to output user name
<?php
// Refer: https://wordpress.stackexchange.com/questions/49686/how-do-i-display-logged-in-username-if-logged-in
// Recommend adding as a code snippet using the code snippets plugin. Can also add to functions.php but will need to remember to transfer if change theme
function mysite_custom_shortcode_makers() {
if( is_user_logged_in() ) {
$user = wp_get_current_user();
return '<h2>Hello ' . $user->first_name . ', welcome to your shop dashboard!</h2>';
}
@adriannees
adriannees / nag-and-prevent-checkout.php
Last active September 29, 2018 15:07
Limit downloads on EDD
<?php
// Add this to the functions.php file on your child theme
/** Limit download purchases to one per account
* HT to Scott Deluzio for original code this is modified from https://scottdeluzio.com/easy-digital-downloads-limit-one-per-customer/
// Give nag message if customer has bought download previously
add_filter( 'edd_can_checkout', 'sd_set_purchase_limit' );
function sd_set_purchase_limit(){
@adriannees
adriannees / exclude-category.php
Created May 9, 2018 15:40
Customize the Jetpack Related Posts Widget
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below into functions.php of your child theme.
//* This code courtesy of Jetpack
function jetpackme_filter_exclude_category( $filters ) {
$filters[] = array( 'not' =>
array( 'term' => array( 'category.slug' => 'category' ) )
); // Replace 'category' with the slug of the category to exclude
return $filters;
}
@adriannees
adriannees / custom-image-size.php
Last active September 6, 2016 23:26
Custom Image Size (WordPress)
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Add new custom image sizes
add_image_size( 'image-name', 150, 100, TRUE );
/* DO NOT include the following it is for instructional purpose only
*
* Replace 'image-name' with the descriptive name you want to identify the new image size with.
* DO NOT use thumb, thumbnail, medium, large, or post-thumbnail
@adriannees
adriannees / Open Graph HTML and header tags
Last active August 29, 2015 14:27 — forked from anneallen/Open Graph HTML and header tags
Add Open Graph HTML and header tags to Genesis Theme
/**Adding the Open Graph in the Language Attributes*/
add_filter('language_attributes', 'child_add_opengraph_doctype');
function child_add_opengraph_doctype( $output ) {
return $output . ' xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"';
}
/** Add Open Graph meta tag to head*/
/* Add this CSS to your store Styles section under CSS mode */
/* http://www.storenvy.com/ */
/* Photo Slider */
.product_photo_slider {
background: #fff; /*: Product Slider Background :*/
border: 5px solid #eaeaea; /*: Product Slider Border :*/
color: #555; /*: Product Slider Product Description :*/
display: block;
margin-left:8px;