This is my functions.php code.
The stuff I added is between the “exit if accessed directly” snippet (not sure what that is), and the “// remove Order Notes from checkout field in Woocommerce” comment.
It’s basically two pieces of code designed to redirect users based on login status and purchase status (for woocommerce checkout)
Could any of this cause an intermittent forbidden error on wp-login?
<?php
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) {
exit;
}
// Redirect users who arent logged in...
function login_redirect() {
// Check to see if user in not logged in and not on the login page
if(!is_user_logged_in() && (is_page(80) || is_page(73) || is_page(197)))
// If user is, Redirect to Login form.
auth_redirect();
}
add_action( 'wp', 'login_redirect' );
//redirect after purchase
add_action( 'template_redirect', 'wc_custom_redirect_after_purchase' );
function wc_custom_redirect_after_purchase() {
global $wp;
if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) {
wp_redirect( 'https://www.lostandfoundpetsneflorida.com/index.php/lostpetpaid999/' );
exit;
}
}
// remove Order Notes from checkout field in Woocommerce
add_filter( 'woocommerce_enable_order_notes_field', '__return_false', 1);
/**
* Gravity Wiz // Gravity Forms // Post Permalink Merge Tag
* https://gravitywiz.com
*/
class GWPostPermalink {
function __construct() {
add_filter('gform_custom_merge_tags', array($this, 'add_custom_merge_tag'), 10, 4);
add_filter('gform_replace_merge_tags', array($this, 'replace_merge_tag'), 10, 3);
}
function add_custom_merge_tag($merge_tags, $form_id, $fields, $element_id) {
if(!GFCommon::has_post_field($fields))
return $merge_tags;
$merge_tags[] = array('label' => 'Post Permalink', 'tag' => '{post_permalink}');
return $merge_tags;
}
function replace_merge_tag($text, $form, $entry) {
$custom_merge_tag = '{post_permalink}';
if(strpos($text, $custom_merge_tag) === false || !rgar($entry, 'post_id'))
return $text;
$post_permalink = get_permalink(rgar($entry, 'post_id'));
$text = str_replace($custom_merge_tag, $post_permalink, $text);
return $text;
}
}
new GWPostPermalink();
//END Permalink Code
/**
*
* WARNING: Please do not edit this file in any way
*
* load the theme function files
*/
$template_directory = get_template_directory();
require( $template_directory . '/core/includes/functions.php' );
require( $template_directory . '/core/includes/functions-update.php' );
require( $template_directory . '/core/includes/functions-sidebar.php' );
require( $template_directory . '/core/includes/functions-install.php' );
require( $template_directory . '/core/includes/functions-admin.php' );
require( $template_directory . '/core/includes/functions-extras.php' );
require( $template_directory . '/core/includes/functions-extentions.php' );
require( $template_directory . '/core/includes/theme-options/theme-options.php' );
require( $template_directory . '/core/includes/post-custom-meta.php' );
require( $template_directory . '/core/includes/tha-theme-hooks.php' );
require( $template_directory . '/core/includes/hooks.php' );
require( $template_directory . '/core/includes/version.php' );
require( $template_directory . '/core/includes/upsell/theme-upsell.php' );
require( $template_directory . '/core/includes/customizer.php' );
// Return value of the supplied responsive free theme option.
function responsive_free_get_option( $option, $default = false ) {
global $responsive_options;
// If the option is set then return it's value, otherwise return false.
if ( isset( $responsive_options[$option] ) ) {
return $responsive_options[$option];
}
return $default;
}