Example #1
0
function host_registration_form($atts)
{
    if (is_user_logged_in() && !rah_is_registered_host()) {
        global $current_user;
        get_currentuserinfo();
        ?>
		<div class="rah-before-form"></div>
		<div id="postbox" class="rah-form">

			<form id="new_host" name="new_post" method="post" action="<?php 
        echo get_page_link();
        ?>
">
				<p>
					<h4>Hi <?php 
        echo $current_user->user_firstname;
        ?>
,</h4>
					Please fill out the following information in order to register yourself as a Co-Op Host. Registering as a host allows
					you to receive notifications of new reviews.
				</p>

				<label for="title"><h4>Host Name</h4></label>
				<p><input size="50" id="title" name="host_title" readonly type="text" value="<?php 
        echo $current_user->user_firstname . ' ' . $current_user->user_lastname;
        ?>
" /></p>
				<label for="group_input"><h4>Group Name</h4></label>
				<p>
					<label for="is_private">My Group is marked "Secret"</label><input id="is_secret" name="is_secret" type="checkbox" value="is_secret" value="1" />
					<input id="group_input" size="50" name="host_group" type="text" value="" placeholder="Your Group Name" />
					<input id="group_name" size="50" name="group_name" type="text" value="" placeholder="Your Group Name" style="display: none;" />
					<span class="rah-loading"></span>
					<div class="hidden" id="response"></div>
				</p>

				<label for="group-type"><h4>Group Type</h4></label>
				<?php 
        $args = array('orderby' => 'ID', 'order' => 'ASC', 'show_count' => 0, 'hide_empty' => 0, 'echo' => 1, 'selected' => 0, 'name' => 'cat', 'id' => '', 'class' => 'postform', 'depth' => 0, 'tab_index' => 0, 'taxonomy' => 'type', 'hide_if_empty' => false);
        ?>
				<p><?php 
        wp_dropdown_categories($args);
        ?>
</p>

				<p>
					<label for="zip_code"><h4>Zip Code</h4></label>
					This is an optional field. Providing your zip code will allow users to search for groups in the near future based off of the hosts location.
					<br />
					<input value= "" type="text" maxlength="5" size="5" name="zip_code" id="zip_code" pattern="[\d]{5}" placeholder="12345" />
					<input type="submit" id="verify_zip_code" value="Check" disabled="disabled" /><span class="rah-loading"></span>
					<span id="city_state"></span>
				</p>

				<p><input type="submit" value="Submit" tabindex="6" id="submit" name="submit" /></p>


				<input type="hidden" name="type" id="type" value="hosts" />
				<input type="hidden" name="rah-action" value="register-host" />
				<?php 
        wp_nonce_field('rah-new-host');
        ?>

			</form>
		</div>
		<div class="rah-after-form"></div>
	<?php 
    } elseif (!is_user_logged_in()) {
        ?>
		<p>
			<strong><em>You must be logged in<sup>*</sup> to register as a Co-Op Host</em></strong>.
		</p>
		<?php 
        sc_render_login_form_social_connect(array('display_label' => false));
        ?>
		<p class="fine-print">
			<sup>*Please login with the Facebook profile associated with your host activities.</sup>
		</p>
		<?php 
    } elseif (rah_is_registered_host()) {
        global $current_user;
        get_currentuserinfo();
        $host_id = get_host_id_from_user_id($current_user->ID);
        $host_status = get_post_status($host_id);
        $host_postal_code = get_post_meta($host_id, '_user_postal_code', true);
        switch ($host_status) {
            case 'publish':
                $status = 'Approved';
                break;
            case 'pending':
                $status = 'Pending Approval';
                break;
            case 'declined':
                $status = 'Declined';
                break;
            default:
                $status = ' - ';
        }
        $parent = get_post_ancestors($host_id);
        $group_name = '';
        $group_link = '';
        $group_fb_id = '';
        if ($parent) {
            $group_url = get_permalink($parent[0]);
            $group_name = get_the_title($parent[0]);
            $group_fb_id = get_post_meta($parent[0], '_rah_group_fb_id', true);
            if (!empty($group_fb_id)) {
                $group_link = 'https://facebook.com/' . $group_fb_id;
            }
        }
        ?>
		<div class="rah-before-form">
			<p id="host-status">
				<strong>Current Status:&nbsp;</strong><?php 
        echo $status;
        ?>
			</p>
			<p id="group-association">
				<strong>Current Group:&nbsp;</strong>
				<?php 
        if ($parent) {
            ?>
					<?php 
            echo $group_name;
            ?>
				<?php 
        }
        ?>
				<?php 
        if (empty($parent)) {
            ?>
					No Current Group Association
				<?php 
        }
        ?>
				<a href="#" id="host-edit-group">&nbsp;&nbsp;Edit Profile</a>
			</p>
		</div>
		<div id="postbox" class="rah-form" style="display: none;">
			<form id="new_host" name="new_post" method="post" action="<?php 
        echo get_page_link();
        ?>
">
				<label for="group_input"><h4>Group Name</h4></label>
				<p>
					<label for="is_private">My Group is marked "Secret"</label><input id="is_secret" name="is_secret" type="checkbox" value="is_secret" value="1" <?php 
        checked(true, empty($group_fb_id), true);
        ?>
 />
					<input id="group_input" size="50" name="host_group" type="text" value="<?php 
        echo $group_name;
        ?>
" placeholder="Your Group Name" />
					<input id="group_name" size="50" name="group_name" type="text" value="<?php 
        echo $group_name;
        ?>
" placeholder="Your Group Name" style="display: none;" />
					<span class="rah-loading"></span>
					<div class="hidden" id="response">
						<?php 
        if (!empty($group_fb_id)) {
            ?>
							<input type="hidden" name="group_id" value="<?php 
            echo $group_fb_id;
            ?>
" />
						<?php 
        }
        ?>
					</div>
				</p>

				<label for="group-type"><h4>Group Type</h4></label>
				<?php 
        $args = array('orderby' => 'ID', 'order' => 'ASC', 'show_count' => 0, 'hide_empty' => 0, 'echo' => 1, 'selected' => 0, 'name' => 'cat', 'id' => '', 'class' => 'postform', 'depth' => 0, 'tab_index' => 0, 'taxonomy' => 'type', 'hide_if_empty' => false);
        ?>
				<p><?php 
        wp_dropdown_categories($args);
        ?>
</p>

				<p>
					<label for="zip_code"><h4>Zip Code</h4></label>
					This is an optional field. Providing your zip code will allow users to search for groups in the near future based off of the hosts location.
					<br />
					<input value="<?php 
        echo $host_postal_code;
        ?>
" type="text" maxlength="5" size="5" name="zip_code" id="zip_code" pattern="[\d]{5}" placeholder="12345" />
					<input type="submit" id="verify_zip_code" value="Check" <?php 
        if (strlen($host_postal_code) < 5) {
            ?>
disabled="disabled" <?php 
        }
        ?>
 /><span class="rah-loading"></span>
					<span id="city_state"></span>
				</p>

				<p><input type="submit" value="Submit" tabindex="6" id="submit" name="submit" /></p>


				<input type="hidden" name="type" id="type" value="hosts" />
				<input type="hidden" name="rah-action" value="register-host" />
				<?php 
        wp_nonce_field('rah-new-host');
        ?>
			</form>
		</div>
		<hr />
		<div>
			<h5>Host Settings</h5>
			<form id="host-settings" method="post" action="<?php 
        echo get_page_link();
        ?>
">
				<p id="host-settings">
				<?php 
        $no_emails = get_post_meta($host_id, '_no_review_optout', true);
        ?>
				<input type="checkbox" id="host_email_optout" name="host_email_optout" value="1" <?php 
        checked('1', $no_emails, true);
        ?>
 />
				&nbsp;<label for="host_email_optout"><strong>Do not</strong> send me emails when I get new reviews</label>
				</p>
				<input type="hidden" name="rah-action" value="edit-host" />
				<input type="hidden" name="host_id" value="<?php 
        echo $host_id;
        ?>
" />
				<?php 
        wp_nonce_field('edit-host', 'rah_edit_host', false, true);
        ?>
				<input type="submit" value="Save Settings" />
			</form>
		</div>
		<div class="rah-after-form"></div>
		<?php 
    }
}
Example #2
0
    function widget($args, $instance)
    {
        if (!is_user_logged_in()) {
            return;
        }
        global $current_user;
        get_currentuserinfo();
        ?>
		<div class="user-widet-wraper">
			<div class="user-avatar"><?php 
        echo get_avatar($current_user->ID, 50);
        ?>
</div>
			<strong>Logged In As:</strong> <?php 
        echo $current_user->user_firstname;
        ?>
			<ul>
				<?php 
        if (current_user_can('edit_posts')) {
            ?>
<li><a href="/wp-admin/">Admin Dashboard</a></li><?php 
        }
        ?>
				<?php 
        if (rah_is_registered_host()) {
            ?>
<li><a href="/host-dashboard">Host Dashboard</a></li><?php 
        }
        ?>
				<li><a href="<?php 
        echo wp_logout_url(get_bloginfo('url'));
        ?>
">Log Out</a></li>
			</ul>
		</div>
		<?php 
    }