Skip to content

Instantly share code, notes, and snippets.

View moafzalmulla's full-sized avatar
😃

Mohamed Afzal Mulla moafzalmulla

😃
View GitHub Profile
@moafzalmulla
moafzalmulla / docker_wordpress.md
Created October 9, 2019 21:39 — forked from bradtraversy/docker_wordpress.md
Docker Compose FIle For Wordpress, MySQL & phpmyadmin

Wordpress & Docker

This file will setup Wordpress, MySQL & PHPMyAdmin with a single command. Add the code below to a file called "docker-compose.yaml" and run the command

$ docker-compose up -d

# To Tear Down
$ docker-compose down --volumes
@moafzalmulla
moafzalmulla / gatsby-heroku-settings.js
Created March 11, 2019 13:41
Deploying Gatsby to Heroku
//package.json
//add new section for engines
"engines": {
"node": "^8.0.0",
"yarn": "^1.2.1"
},
//add 2 new functions to scripts
"scripts": {
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
@moafzalmulla
moafzalmulla / manual-gravity-forms
Created May 18, 2017 10:05 — forked from keithdevon/manual-gravity-forms
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",
@moafzalmulla
moafzalmulla / Register with email : Wordpress
Created May 21, 2016 13:43
Add this to functions.php then the person will be able to reg with email as username
// register with email
function custom_register_with_email($result) {
if ( $result['user_name'] != '' && is_email( $result['user_name'] ) ) {
unset( $result['errors']->errors['user_name'] );
}
return $result;
@moafzalmulla
moafzalmulla / Gravity forms login form
Last active May 21, 2016 13:41
This code must sit is functions.php if you need a GF login form with he parameters username & password
// You must set the css classes of both input fields to username and password respectively for this to work
// Code forums - cant remember exactly link
// the _3 prefix has to match the id of the form you have created
add_action( "gform_after_submission_20", "login_form_after_submission_20", 10, 2 );
function login_form_after_submission_20($entry, $form) {
// get the username and pass
$username = $entry[1];
$pass = $entry[2];
$creds = array();
@moafzalmulla
moafzalmulla / Get Taxomy Terms for a specific custom post
Last active May 7, 2016 13:48
Below is a function that will sit in functions.php. In order to call it use <?php $tax="NameOfTaxonomy"; renderTaxonomySlug($tax); ?>
<?php
function renderTaxonomySlug($tax){
$terms = get_the_terms( $post->ID, $tax );
if ( !empty( $terms ) ){
// get the first term
$term = array_shift( $terms );
//echo $term->slug;
}
$taxonomy=$tax;
@moafzalmulla
moafzalmulla / functions.php
Created April 4, 2016 10:35
Gravity forms 2 login forms with form id's of 17 and 20 . When functions are duplicated site breaks. When class is changed of one form, to avoid class clash still doesnt work. Duplicated forms below.
// ++++++++++++ 1st form - id 17 ++++++++++++++
// the _3 prefix has to match the id of the form you have created
add_action( "gform_after_submission_17", "login_form_after_submission", 10, 2 );
function login_form_after_submission($entry, $form) {
// get the username and pass
$username = $entry[1];
$pass = $entry[2];
$creds = array();
// create the credentials array
$creds['user_login'] = $username;
@moafzalmulla
moafzalmulla / Postcode Validator
Created March 14, 2016 15:25 — forked from BrettBailey/Postcode Validator
UK Postcode Validator using angular js and ng-pattern. Full Explanation at http://www.clearcoders.co.uk/
<div class="form-group">
<div class="col-xs-7">
<label for="postcode">Postcode</label>
<input type="text" name="postcode" placeholder="Postcode" ng-pattern="/^[a-z]{1,2}[0-9][a-z0-9]?\s?[0-9][a-z]{2}$/i" required ng-minlength="5" ng-maxlength="8" ng-model="complaint.postcode" ng-change="formatPostcode()" class="form-control" />
<div class="col-xs-12" ng-messages="reclaim.postcode.$error" ng-if="reclaim.$submitted || reclaim.postcode.$dirty">
<div class="text-warning" ng-message="minlength">Postcode is too short.</div>
<div class="text-warning" ng-message="pattern">Postcode is not in the correct format.</div>
<div class="text-warning" ng-message="maxlength">Postcode is too long.</div>
</div>
</div>