<?php
/*
Template Name: Submit Give Form
*/

/**
 * @package WordPress
 * @subpackage Campoal
 */

global $campoal_options;
global $post;

if (!is_user_logged_in() || !class_exists('Give')) {
    $login_page = isset($campoal_options['conikal_page_login_field']) ? $campoal_options['conikal_page_login_field'] : 0;

    if ($login_page != 0 && !is_user_logged_in()) {
        $login_page = get_permalink($login_page);
        $login_page = add_query_arg('referer', $post->ID, $login_page);
        wp_redirect($login_page);
    } else {
        // wp_redirect(home_url('/'));
    }
}

if (!is_user_logged_in()) {
    conikal_redirect_login();
} else {
    $admin_submit_petition_only = isset($campoal_options['conikal_admin_submit_petition_only_field']) ? $campoal_options['conikal_admin_submit_petition_only_field'] : 0;

    if ($admin_submit_petition_only == 1) { 
        if (!current_user_can('manage_options')) {
            wp_redirect(home_url('/'));
        }
    }
}

get_header();
?>

<?php if (class_exists('Give')) { ?>
    <div id="wrapper" class="wrapper read petition">
        <div class="ui container submit-petition">
            <?php get_template_part( 'templates/submition/submit', 'fundraising' );  ?>
        </div>
    </div>
<?php } else { ?>
    <?php get_template_part('404') ?>
<?php } ?>

<?php get_footer(); ?>