public function load_user()
 {
     if ($this->id > 0) {
         $current_user = get_user_by('ID', $this->id);
     } elseif (function_exists('is_user_logged_in') && is_user_logged_in()) {
         $current_user = wp_get_current_user();
     }
     if (isset($current_user) && $current_user) {
         $this->id = $current_user->ID;
         $this->first_name = $current_user->user_firstname;
         $this->last_name = $current_user->user_lastname;
         $this->email = $current_user->user_email;
         $this->address = get_user_meta($current_user->ID, 'address', TRUE);
         $this->is_on_mailing_list = get_user_meta($current_user->ID, 'mailing_list', TRUE);
         $this->is_on_mailing_list = $this->is_on_mailing_list == 1 ? TRUE : FALSE;
         $neighborhood_id = get_user_meta($current_user->ID, 'neighborhood_id', TRUE);
         if (!empty($neighborhood_id) && $neighborhood_id > 0) {
             $args = array('post_type' => 'wbb_neighborhood', 'post_status' => 'publish');
             $query = new \WP_Query($args);
             while ($query->have_posts()) {
                 $query->the_post();
                 if (get_the_ID() == $neighborhood_id) {
                     $this->neighborhood = new Neighborhood();
                     $this->neighborhood->post_id = get_the_ID();
                     $this->neighborhood->title = get_the_title();
                     break;
                 }
             }
         }
         $this->get_locations();
     }
 }
function create_listings()
{
    global $wpdb, $bp;
    $current_user = wp_get_current_user();
    //categories
    $user_ID = $bp->displayed_user->id;
    if (isset($_POST["save_bepro_listing"]) && !empty($_POST["save_bepro_listing"])) {
        $success = false;
        $success = bepro_listings_save();
        if ($success) {
            $message = urlencode("Success saving listing");
        } else {
            $message = urlencode("Error saving listing");
        }
        $current_user = wp_get_current_user();
        $bp_profile_link = bp_core_get_user_domain($bp->displayed_user->id);
        wp_redirect($bp_profile_link . BEPRO_LISTINGS_SLUG . "?message=" . $message);
        exit;
    } elseif (isset($bp->action_variables[0]) && $bp->current_action == BEPRO_LISTINGS_CREATE_SLUG) {
        add_action('bp_template_content', 'update_listing_content');
    } else {
        add_action('bp_template_content', 'create_listing_content');
    }
    bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
}
Example #3
0
 function record_coupon_application($sub_id = false, $pricing = false)
 {
     global $blog_id;
     $global = defined('MEMBERSHIP_GLOBAL_TABLES') && filter_var(MEMBERSHIP_GLOBAL_TABLES, FILTER_VALIDATE_BOOLEAN);
     // Create transient for 1 hour.  This means the user has 1 hour to redeem the coupon after its been applied before it goes back into the pool.
     // If you want to use a different time limit use the filter below
     $time = apply_filters('membership_apply_coupon_redemption_time', HOUR_IN_SECONDS);
     // Grab the user account as we should be logged in by now
     $user = wp_get_current_user();
     $transient_name = 'm_coupon_' . $blog_id . '_' . $user->ID . '_' . $sub_id;
     $transient_value = array('coupon_id' => $this->_coupon->id, 'user_id' => $user->ID, 'sub_id' => $sub_id, 'prices_w_coupon' => $pricing);
     // Check if a transient already exists and delete it if it does
     if ($global && function_exists('get_site_transient')) {
         $trying = get_site_transient($transient_name);
         if ($trying != false) {
             // We have found an existing coupon try so remove it as we are using a new one
             delete_site_transient($transient_name);
         }
         set_site_transient($transient_name, $transient_value, $time);
     } else {
         $trying = get_transient($transient_name);
         if ($trying != false) {
             // We have found an existing coupon try so remove it as we are using a new one
             delete_transient($transient_name);
         }
         set_transient($transient_name, $transient_value, $time);
     }
 }
 private function saveToStore($subject, $requestBody, $actionType)
 {
     $property = json_decode($requestBody);
     $predicate = $property->key;
     $value = $property->value;
     $language = $property->lang;
     $type = $property->type;
     $datatype = $property->datatype;
     $subject = "http://dbpedia.org/resource/{$subject}";
     $predicates = array($predicate => array(array("value" => $value, "type" => $type)));
     if (!empty($language)) {
         $predicates[$predicate][0]["lang"] = $language;
     }
     if (!empty($datatype)) {
         $predicates[$predicate][0]["datatype"] = $datatype;
     }
     $currentUser = wp_get_current_user();
     $currentUserName = $currentUser->user_login;
     switch ($actionType) {
         case self::TYPE_DELETE:
             $this->changeSetService->saveChanges($subject, $currentUserName, array(), $predicates, "User request");
             break;
         case self::TYPE_UPDATE:
             $this->changeSetService->saveChanges($subject, $currentUserName, $predicates, array(), "User request");
             break;
     }
 }
 function Save_Report_Message()
 {
     $current_user = wp_get_current_user();
     $email_name = $current_user->user_firstname . ' ' . $current_user->user_lastname . ' - ' . $current_user->user_email;
     $date = date('Y-m-d H:i:s');
     $message = $this->posts['POST_MESSAGE'];
     $post = array('post_content' => $message, 'post_name' => $email_name, 'post_title' => $email_name, 'post_status' => 'publish', 'post_type' => 'collab-msg-rep', 'post_author' => get_current_user_id(), 'ping_status' => 'close', 'post_parent' => '0', 'menu_order' => '0', 'to_ping' => '', 'pinged' => '', 'post_password' => '', 'post_date' => $date, 'comment_status' => 'closed');
     $page_id = wp_insert_post($post);
     if (isset($this->posts['attachments']) && is_array($this->posts['attachments'])) {
         update_post_meta($page_id, '_wp_collaboration_attachments', $this->posts['attachments']);
     }
     update_post_meta($page_id, 'Report_Id', $this->posts['Report_Id']);
     /* send Emails */
     $Alert_Title = get_the_author_meta('display_name', get_current_user_id()) . ' sent  you a message ' . identity(array('Workroom_Id' => $this->posts['Report_Id'], 'Type' => 'Report', 'Collaborator_Id' => get_post_field('post_author', $this->posts['Report_Id'])));
     $ReportAlert = new stdClass();
     $ReportAlert->Collaborator_Name = get_the_author_meta('display_name', get_post_field('post_author', $this->posts['Report_Id']));
     $ReportAlert->Notification_From = get_the_author_meta('display_name', get_current_user_id());
     $ReportAlert->Message = nl2br($message);
     ob_start();
     include collaboration_plugin_dir . 'templates/frontend/emails/collaboration-report-a-problem-template.php';
     $Get_Template = ob_get_clean();
     ob_start();
     include collaboration_plugin_dir . 'templates/frontend/emails/collaboration-email-css.php';
     $css = ob_get_clean();
     //Add Alert
     //End Add Alerts
     wp_mail('*****@*****.**', $Alert_Title, $css . $Get_Template);
     wp_mail(get_the_author_meta('user_email', $this->posts['Report_Id']), $Alert_Title, $css . $Get_Template);
     /* End send email */
     //End Adding notifications and emails
     echo json_encode($son);
 }
Example #6
0
function AtD_redirect_call()
{
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        $postText = trim(file_get_contents('php://input'));
    }
    $url = $_GET['url'];
    $service = apply_filters('atd_service_domain', 'service.afterthedeadline.com');
    if (defined('WPLANG')) {
        if (strpos(WPLANG, 'pt') !== false) {
            $service = 'pt.service.afterthedeadline.com';
        } else {
            if (strpos(WPLANG, 'de') !== false) {
                $service = 'de.service.afterthedeadline.com';
            } else {
                if (strpos(WPLANG, 'es') !== false) {
                    $service = 'es.service.afterthedeadline.com';
                } else {
                    if (strpos(WPLANG, 'fr') !== false) {
                        $service = 'fr.service.afterthedeadline.com';
                    }
                }
            }
        }
    }
    $user = wp_get_current_user();
    $guess = strcmp(AtD_get_setting($user->ID, 'AtD_guess_lang'), "true") == 0 ? "true" : "false";
    $data = AtD_http_post($postText . "&guess={$guess}", defined('ATD_HOST') ? ATD_HOST : $service, $url, defined('ATD_PORT') ? ATD_PORT : 80);
    header('Content-Type: text/xml');
    if (!empty($data[1])) {
        echo $data[1];
    }
    die;
}
Example #7
0
function wppb_check_email_value($message, $field, $request_data, $form_location)
{
    global $wpdb;
    if (isset($request_data['email']) && trim($request_data['email']) == '' && $field['required'] == 'Yes') {
        return wppb_required_field_error($field["field-title"]);
    }
    if (isset($request_data['email']) && !is_email(trim($request_data['email']))) {
        return __('The email you entered is not a valid email address.', 'profilebuilder');
    }
    if (is_multisite() || !is_multisite() && (isset($wppb_generalSettings['emailConfirmation']) && $wppb_generalSettings['emailConfirmation'] == 'yes')) {
        $user_signup = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "signups WHERE user_email = %s", $request_data['email']));
        if (!empty($user_signup)) {
            return __('This email is already reserved to be used soon.', 'profilebuilder') . '<br/>' . __('Please try a different one!', 'profilebuilder');
        }
    }
    $users = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->users} WHERE user_email = %s", $request_data['email']));
    if (!empty($users)) {
        if ($form_location == 'register') {
            return __('This email is already in use.', 'profilebuilder') . '<br/>' . __('Please try a different one!', 'profilebuilder');
        }
        if ($form_location == 'edit_profile') {
            $current_user = wp_get_current_user();
            foreach ($users as $user) {
                if ($user->ID != $current_user->ID) {
                    return __('This email is already in use.', 'profilebuilder') . '<br/>' . __('Please try a different one!', 'profilebuilder');
                }
            }
        }
    }
    return $message;
}
function wptutsplus_remove_comments_menu_item()
{
    $user = wp_get_current_user();
    if (!$user->has_cap('manage_options')) {
        remove_menu_page('edit-comments.php');
    }
}
/**
 * Hide update notices for all but me
 */
function _s_hide_update_notices_all()
{
    if (wp_get_current_user()->user_login !== 'sean') {
        global $wp_version;
        return (object) array('last_checked' => time(), 'version_checked' => $wp_version);
    }
}
/**
 * Remove items in Admin Bar for current role of current active user in front end area
 * Exclude Super Admin, if active
 * Exclude Settings page of Adminimize
 *
 * @since   1.8.1  01/10/2013
 */
function _mw_adminimize_change_admin_bar()
{
    // Only for users, there logged in.
    if (!is_user_logged_in()) {
        return;
    }
    // Exclude super admin.
    if (_mw_adminimize_exclude_super_admin()) {
        return;
    }
    /** @var $wp_admin_bar WP_Admin_Bar */
    global $wp_admin_bar;
    // Get current user data.
    $user = wp_get_current_user();
    if (!$user->roles[0]) {
        return;
    }
    $user_role = $user->roles[0];
    // Get Backend Admin Bar settings for the current user role.
    if (is_admin()) {
        $disabled_admin_bar_option_[$user_role] = _mw_adminimize_get_option_value('mw_adminimize_disabled_admin_bar_' . $user_role . '_items');
    } else {
        // Get Frontend Admin Bar settings for the current user role.
        $disabled_admin_bar_option_[$user_role] = (array) _mw_adminimize_get_option_value('mw_adminimize_disabled_admin_bar_frontend_' . $user_role . '_items');
    }
    // No settings for this role, exit.
    if (!$disabled_admin_bar_option_[$user_role]) {
        return;
    }
    foreach ($disabled_admin_bar_option_[$user_role] as $admin_bar_item) {
        $wp_admin_bar->remove_node($admin_bar_item);
    }
}
            function meta_data()
            {
                ?>
                <generator><?php 
                echo WPFront_User_Role_Editor_Export::GENERATOR;
                ?>
</generator>
                <version><?php 
                echo WPFront_User_Role_Editor_Export::VERSION;
                ?>
</version>
                <date><?php 
                echo date('D, d M Y H:i:s +0000');
                ?>
</date>
                <source><?php 
                bloginfo_rss('name');
                ?>
</source>
                <source_url><?php 
                bloginfo_rss('url');
                ?>
</source_url>
                <user_display_name><?php 
                echo cdata(wp_get_current_user()->display_name);
                ?>
</user_display_name>
                <user_id><?php 
                echo wp_get_current_user()->ID;
                ?>
</user_id>
                <?php 
            }
Example #12
0
 /**
  * Returns currently loggedin user employer object
  *
  * @return Wpjb_Model_Employer
  */
 public static function current()
 {
     if (self::$_current instanceof self) {
         return self::$_current;
     }
     $current_user = wp_get_current_user();
     if ($current_user->ID < 1) {
         return new self();
     }
     $query = new Daq_Db_Query();
     $object = $query->select()->from(__CLASS__ . " t")->where("user_id = ?", $current_user->ID)->limit(1)->execute();
     if ($object[0]) {
         self::$_current = $object[0];
         return self::$_current;
     }
     // quick create
     $object = new self();
     $object->user_id = $current_user->ID;
     $object->company_name = "";
     $object->company_website = "";
     $object->company_info = "";
     $object->company_logo_ext = "";
     $object->company_location = "";
     $object->is_public = 0;
     $object->is_active = self::ACCOUNT_ACTIVE;
     $object->save();
     self::$_current = $object;
     return $object;
 }
 private function get_current_user_id()
 {
     global $current_user;
     $current_user = wp_get_current_user();
     $user_id = $current_user->ID;
     return $user_id;
 }
/**
 * Template function for adding new contacts
 * @since 0.1
 */
function rolo_add_contact()
{
    $user = wp_get_current_user();
    if ($user->ID) {
        //TODO - Check user capabilites
        //TODO - Verify nounce here
        if (isset($_POST['rp_add_contact']) && $_POST['rp_add_contact'] == 'add_contact') {
            $contact_id = _rolo_save_contact_fields();
            if ($contact_id) {
                // echo __("Contacto adicionado com sucesso.", 'rolopress');
                $location = get_bloginfo('siteurl');
                echo "<script type='text/javascript'>window.location = '" . $location . "';</script>";
                //header("Location: $location", true, 301);
            } else {
                echo __("Ocorreu um erro ao inserir o contacto, por favor tente novamente.", 'rolopress');
                _rolo_show_contact_fields();
                //            TODO - Handle Error properly
            }
        } elseif (isset($_POST['rp_add_notes']) && $_POST['rp_add_notes'] == 'add_notes') {
            if (_rolo_save_contact_notes()) {
                echo __("Comentários adicionados com sucesso.", 'rolopress');
            } else {
                //            TODO - Handle Error properly
                echo __("Ocorreu um erro ao inserir o comentário", 'rolopress');
            }
        } else {
            _rolo_show_contact_fields();
        }
    }
}
/**
 * mur_block_editing_post()
 *
 * block post editing for different user
 */
function mur_block_editing_post()
{
    $author_id_post = get_the_author_meta('ID');
    $current_user = wp_get_current_user();
    $author_role = $current_user->roles[0];
    $author_id = $current_user->ID;
}
Example #16
0
 /**
  * Clones provided page ID
  * @param  int $pageId
  * @return int
  */
 public function clonePage($pageId)
 {
     $oldPost = get_post($pageId);
     if (null === $oldPost) {
         return 0;
     }
     if ('revision' === $oldPost->post_type) {
         return 0;
     }
     $currentUser = wp_get_current_user();
     $newPost = array('menu_order' => $oldPost->menu_order, 'comment_status' => $oldPost->comment_status, 'ping_status' => $oldPost->ping_status, 'post_author' => $currentUser->ID, 'post_content' => $oldPost->post_content, 'post_excerpt' => $oldPost->post_excerpt, 'post_mime_type' => $oldPost->post_mime_type, 'post_parent' => $oldPost->post_parent, 'post_password' => $oldPost->post_password, 'post_status' => $oldPost->post_status, 'post_title' => '(dup) ' . $oldPost->post_title, 'post_type' => $oldPost->post_type, 'post_date' => $oldPost->post_date, 'post_date_gmt' => get_gmt_from_date($oldPost->post_date));
     $newId = wp_insert_post($newPost);
     /*
      * Generating unique slug
      */
     if ($newPost['post_status'] == 'publish' || $newPost['post_status'] == 'future') {
         $postName = wp_unique_post_slug($oldPost->post_name, $newId, $newPost['post_status'], $oldPost->post_type, $newPost['post_parent']);
         $newPost = array();
         $newPost['ID'] = $newId;
         $newPost['post_name'] = $postName;
         wp_update_post($newPost);
     }
     $this->cloneMeta($pageId, $newId);
     $this->cloneOpData($pageId, $newId);
     return $newId;
 }
 /**
  * Adds event type, h5p library and timestamp to event before saving it.
  *
  * @param string $type
  *  Name of event to log
  * @param string $library
  *  Name of H5P library affacted
  */
 function __construct($type, $sub_type = NULL, $content_id = NULL, $content_title = NULL, $library_name = NULL, $library_version = NULL)
 {
     // Track the user who initiated the event as well
     $current_user = wp_get_current_user();
     $this->user = $current_user->ID;
     parent::__construct($type, $sub_type, $content_id, $content_title, $library_name, $library_version);
 }
function px_verified_check_user_topic($have_posts)
{
    if (is_user_logged_in()) {
        global $wp_roles;
        $current_user = wp_get_current_user();
        $roles = $current_user->roles;
        $role = array_shift($roles);
        $forum_name = single_post_title('', false);
        if ($role == 'bbp_keymaster' || $role == 'bbp_moderator' || $role == 'administrator' || $role == 'editor') {
        } else {
            if ($role == 'px_wpba_customer' && $forum_name == 'WordPress Blog Android App' || $forum_name == 'WP Google Cloud Messaging' || $forum_name == 'Special Threads from us') {
            } else {
                if ($role == 'px_wpgcm_customer' && $forum_name == 'WP Google Cloud Messaging' || $forum_name == 'Special Threads from us') {
                } else {
                    echo '<div class="bbp-template-notice"><p>Sorry, but you do not have the capability to view this forum</p></div>';
                    return $have_posts = null;
                }
            }
        }
        return $have_posts;
    } else {
        echo '<div class="bbp-template-notice"><p>Sorry, but you do not have the capability to view this topic</p></div>';
        return $have_posts = null;
    }
}
 /**
  * Verify that correct nonce was used with time limit.
  *
  * The user is given an amount of time to use the token, so therefore, since the
  * UID and $action remain the same, the independent variable is the time.
  *
  * @since 2.0.3
  *
  * @param string $nonce Nonce that was used in the form to verify
  * @param string|int $action Should give context to what is taking place and be the same when nonce was created.
  *
  * @return false|int False if the nonce is invalid, 1 if the nonce is valid and generated between
  *                   0-12 hours ago, 2 if the nonce is valid and generated between 12-24 hours ago.
  */
 function wp_verify_nonce($nonce, $action = -1)
 {
     $nonce = (string) $nonce;
     $user = wp_get_current_user();
     $uid = (int) $user->ID;
     if (!$uid) {
         /**
          * Filter whether the user who generated the nonce is logged out.
          *
          * @since 3.5.0
          *
          * @param int $uid ID of the nonce-owning user.
          * @param string $action The nonce action.
          */
         $uid = apply_filters('nonce_user_logged_out', $uid, $action);
     }
     if (empty($nonce)) {
         die('<mainwp>' . base64_encode(json_encode(array('error' => 'You dont send nonce: ' . $action))) . '</mainwp>');
     }
     $token = wp_get_session_token();
     $i = wp_nonce_tick();
     // Nonce generated 0-12 hours ago
     $expected = substr(wp_hash($i . '|' . $action . '|' . $uid . '|' . $token, 'nonce'), -12, 10);
     if (hash_equals($expected, $nonce)) {
         return 1;
     }
     // Nonce generated 12-24 hours ago
     $expected = substr(wp_hash($i - 1 . '|' . $action . '|' . $uid . '|' . $token, 'nonce'), -12, 10);
     if (hash_equals($expected, $nonce)) {
         return 2;
     }
     // Invalid nonce
     die('<mainwp>' . base64_encode(json_encode(array('error' => 'Invalid nonce. Try use: ' . $action))) . '</mainwp>');
 }
 public function dispatch()
 {
     // Check there are categories available
     if (count(get_terms(WPBDP_CATEGORY_TAX, array('hide_empty' => false))) == 0) {
         if (current_user_can('administrator')) {
             return wpbdp_render_msg(_x('There are no categories assigned to the business directory yet. You need to assign some categories to the business directory. Only admins can see this message. Regular users are seeing a message that they cannot add their listing at this time. Listings cannot be added until you assign categories to the business directory.', 'templates', 'WPBDM'), 'error');
         } else {
             return wpbdp_render_msg(_x('Your listing cannot be added at this time. Please try again later. If this is not the first time you see this warning, please ask the site administrator to set up one or more categories inside the Directory.', 'templates', 'WPBDM'), 'error');
         }
     }
     // Login required?
     if (wpbdp_get_option('require-login') && !is_user_logged_in()) {
         return wpbdp_render('parts/login-required', array(), false);
     }
     if ($this->state->editing) {
         $current_user = wp_get_current_user();
         if (get_post($this->state->listing_id)->post_author != $current_user->ID && !current_user_can('administrator')) {
             return wpbdp_render_msg(_x('You are not authorized to edit this listing.', 'templates', 'WPBDM'), 'error');
         }
     }
     $callback = 'step_' . $this->state->step;
     if (method_exists($this, $callback)) {
         return call_user_func(array(&$this, $callback));
     } else {
         return 'STEP NOT IMPLEMENTED YET: ' . $this->state->get_step();
     }
 }
 private function __construct()
 {
     if (!class_exists("WC_Payment_Gateway")) {
         return;
     }
     $settings = get_option("woocommerce_omise_settings", null);
     if (is_null($settings) || !is_array($settings)) {
         return;
     }
     if (empty($settings["sandbox"]) || empty($settings["test_private_key"]) || empty($settings["live_private_key"]) || empty($settings["test_public_key"]) || empty($settings["live_public_key"])) {
         return;
     }
     $test_mode = isset($settings["sandbox"]) && "yes" == $settings["sandbox"];
     $this->private_key = $test_mode ? $settings["test_private_key"] : $settings["live_private_key"];
     $this->public_key = $test_mode ? $settings["test_public_key"] : $settings["live_public_key"];
     if (empty($this->private_key) || empty($this->public_key)) {
         return;
     }
     if (is_user_logged_in()) {
         $current_user = wp_get_current_user();
         $this->omise_customer_id = $test_mode ? $current_user->test_omise_customer_id : $current_user->live_omise_customer_id;
     }
     add_action("woocommerce_after_my_account", array($this, "init_panel"));
     add_action("wp_ajax_omise_delete_card", array($this, "omise_delete_card"));
     add_action("wp_ajax_omise_create_card", array($this, "omise_create_card"));
     add_action("wp_ajax_nopriv_omise_delete_card", array($this, "no_op"));
     add_action("wp_ajax_nopriv_omise_create_card", array($this, "no_op"));
 }
function wingsSaveTextForPostAndUserUpdate()
{
    global $wpdb;
    global $wingspersonalplugin_db_version;
    $table_name = $wpdb->prefix . "wingspersonaloverlib";
    $thoughts = $_POST['thoughts'];
    //pegar o post id e o usuário
    $postId = $_POST['id'];
    $user = wp_get_current_user();
    //pegar o trecho
    $text = $_POST['text'];
    $thoughtsId = $_POST['thoughtsId'];
    //salvar no banco
    /*
    $wpdb->insert( 
      $table_name, 
      array( 
        'personal_post_ID' => $postId, 
        'personal_user_ID' => $user->ID, 
        'personal_comment' => $_POST['thoughts'],
        'personal_comment_text' =>  $text,
        ) 
      );
    */
    $wpdb->update($table_name, array('personal_comment' => $thoughts, 'personal_comment_text' => $text), array('ID' => $thoughtsId), array('%s', '%s'), array('%d'));
    //buscar o conteúdo - lembrar de pegar no get content capitular o conteúdo
    the_content_capitular(null, false, $postId);
    //vamos buscar
    return;
}
 public static function check_add_email_inquiry_button($product_id)
 {
     global $wc_email_inquiry_global_settings;
     $wc_email_inquiry_show_button = $wc_email_inquiry_global_settings['show_button'];
     // dont show email inquiry button if setting is not checked and not logged in users
     if ($wc_email_inquiry_show_button == 'no' && !is_user_logged_in()) {
         return false;
     }
     // alway show email inquiry button if setting is checked and not logged in users
     if ($wc_email_inquiry_show_button != 'no' && !is_user_logged_in()) {
         return true;
     }
     $wc_email_inquiry_show_button_after_login = $wc_email_inquiry_global_settings['show_button_after_login'];
     // don't show email inquiry button if for logged in users is deacticated
     if ($wc_email_inquiry_show_button_after_login != 'yes') {
         return false;
     }
     $role_apply_show_inquiry_button = (array) $wc_email_inquiry_global_settings['role_apply_show_inquiry_button'];
     $user_login = wp_get_current_user();
     if (is_array($user_login->roles) && count($user_login->roles) > 0) {
         $role_existed = array_intersect($user_login->roles, $role_apply_show_inquiry_button);
         // show email inquiry button if current user role in list apply role
         if (is_array($role_existed) && count($role_existed) > 0) {
             return true;
         }
     }
     return false;
 }
Example #24
0
 protected function _load_user($user = null)
 {
     if (is_user_logged_in() && !$user) {
         $this->user = wp_get_current_user();
     } else {
         if ($user instanceof WP_User) {
             $this->user = $user;
         } else {
             if (is_integer($user)) {
                 $this->user = get_user_by('id', $user);
             } else {
                 if (is_string($user) && is_email($user)) {
                     $this->user = get_user_by('email', $user);
                 } else {
                     if (is_string($user)) {
                         $this->user = get_user_by('login', $user);
                     }
                 }
             }
         }
     }
     if (!$this->user) {
         $message = __('User not found.', 'crb');
         throw new Exception($message);
     }
     return $this;
 }
 public function process_shortcode($args = array(), $content = '')
 {
     $status = false;
     $args = wp_parse_args($args, $this->_defaults_to_args());
     if (!empty($args['worker_id'])) {
         $args['worker_id'] = $this->_arg_to_int($args['worker_id']);
     } else {
         if (is_user_logged_in()) {
             $worker = wp_get_current_user();
             $args['worker_id'] = $worker->ID;
         } else {
             return $content;
             // We don't know what to show
         }
     }
     if (!$args['worker_id']) {
         return $content;
     }
     $status = $this->_arg_to_string_list($args['status']);
     $args['start_at'] = !empty($args['start_at']) ? strtotime($args['start_at']) : false;
     if (!$args['start_at'] && !empty($_GET['wcalendar']) && is_numeric($_GET['wcalendar'])) {
         $args['start_at'] = (int) $_GET['wcalendar'];
     } else {
         if (!$args['start_at']) {
             $args['start_at'] = current_time('timestamp');
         }
     }
     $appointments = $this->_get_worker_appointments($args['worker_id'], $status, $args['start_at']);
     if (empty($appointments)) {
         return $content;
     }
     return $this->_create_appointments_table($appointments, $args);
     return $content;
 }
 function TS_VCSC_CheckUserRole($roles, $user_id = NULL)
 {
     // Get user by ID, else get current user
     if ($user_id) {
         $user = get_userdata($user_id);
     } else {
         $user = wp_get_current_user();
     }
     // No user found, return
     if (empty($user)) {
         return FALSE;
     }
     // Append administrator to roles, if necessary
     if (!in_array('administrator', $roles)) {
         $roles[] = 'administrator';
     }
     // Loop through user roles
     foreach ($user->roles as $role) {
         // Does user have role
         if (in_array($role, $roles)) {
             return TRUE;
         }
     }
     // User not in roles
     return FALSE;
 }
Example #27
0
 /**
  * @return void
  */
 public function check_exists_token()
 {
     $user = wp_get_current_user();
     if (!$user->ID) {
         wp_logout();
         return false;
     }
     $token = '';
     $pod = pods('jwt_user_token');
     if ($pod) {
         $record = $pod->find(null, 1, "author.ID = {$user->ID}");
         $data = $record->fetch();
         if ($data) {
             $token = isset($data['token']) ? $data['token'] : '';
         } else {
             $data = self::get_jwt_token($user);
             $token = isset($data['token']) ? $data['token'] : '';
         }
     }
     $current_token = isset($_COOKIE['dln_token']) ? $_COOKIE['dln_token'] : '';
     if (!$current_token || $current_token != $token) {
         self::setToken($token);
     }
     return true;
 }
Example #28
0
 function generate_map()
 {
     global $wpdb;
     wp_enqueue_script('google-maps', 'https://maps.google.com/maps/api/js?sensor=true', false, '3');
     wp_register_script('fb-map', plugins_url('js/fb-map.js', __FILE__), false, '1.0', false);
     wp_enqueue_script('fb-map');
     wp_register_style('fb-css', plugins_url('css/fb-map.css', __FILE__), array(), '1.0');
     wp_enqueue_style('fb-css');
     $current_user = wp_get_current_user();
     //echo 'Username: '******'<br />';
     //echo 'User email: ' . $current_user->user_email . '<br />';
     //echo 'User first name: ' . $current_user->user_firstname . '<br />';
     //echo 'User last name: ' . $current_user->user_lastname . '<br />';
     //echo 'User display name: ' . $current_user->display_name . '<br />';
     //echo 'User ID: ' . $current_user->ID . '<br />';
     //$latitude_value = get_cimyFieldValue($current_user->ID, $this->opts['latitude_user_field_name']);
     //$longitude_value = get_cimyFieldValue($current_user->ID, $this->opts['longitude_user_field_name']);
     $user_location_query = "SELECT wfl.lat, wfl.long, wfl.member_id, usermeta.meta_value as facebook_uid FROM wppl_friends_locator wfl JOIN {$wpdb->usermeta} usermeta ON usermeta.user_id = wfl.member_id WHERE member_id =  %d AND meta_key = 'facebook_uid'";
     $user_location = $wpdb->get_results($wpdb->prepare($user_location_query, $current_user->ID));
     if ($user_location && count($user_location) > 0) {
         $user_location = $user_location[0];
     }
     if ($user_location) {
         #Haversine formula
         $query = "SELECT * FROM (SELECT ROUND(6371 * acos(cos(radians(lat_long.lat) ) * cos(radians('%s') ) * cos(radians('%s') - radians(lat_long.lng) ) + sin(radians(lat_long.lat) ) * sin(radians('%s') ) ), 3) AS distance,\n                             user_id,\n                             lat,\n                             lng,\n                             display_name,\n                             facebook_uid\n                          FROM (\n                                   SELECT loc.member_id AS user_id,\n                                          loc.lat AS lat,\n                                          loc.long AS lng,\n                                          usr.display_name AS display_name,\n                                          usrmeta.meta_value AS facebook_uid\n                                     FROM\n                                          wppl_friends_locator loc\n\n                                     JOIN\n                                          {$wpdb->users} usr ON loc.member_id = usr.ID\n                                     JOIN\n                                          {$wpdb->usermeta} usrmeta ON usr.ID = usrmeta.user_id\n                                     WHERE\n                                          loc.member_id <> %d\n                                          AND\n                                           meta_key = 'facebook_uid') lat_long) lat_long_tbl\n                          WHERE lat_long_tbl.distance <= '%f'";
         $nearby_users = $wpdb->get_results($wpdb->prepare($query, $user_location->lat, $user_location->long, $user_location->lat, $current_user->ID, $this->opts['distance_from_user']));
         echo "<script type=\"text/javascript\">\n";
         echo "var userLat = " . $user_location->lat . ";";
         echo "var userLong = " . $user_location->long . ";";
         if ($nearby_users) {
             echo "var plainLocations = [\n";
             echo "[" . $user_location->lat . ", " . $user_location->long . ",'" . $current_user->display_name . "', '0', '" . $current_user->facebook_uid . "'],\n";
             foreach ($nearby_users as $nearby_user) {
                 echo "[" . $nearby_user->lat . ", " . $nearby_user->lng . ",'" . $nearby_user->display_name . "'," . $nearby_user->distance . ",'" . $nearby_user->facebook_uid . "'],\n";
             }
             echo "];\n";
             echo "</script>\n";
             echo "<br/>";
             echo "<p>";
             printf(__("List of nearby users: %d \n <br/>", "epinoo-fb-map"), count($nearby_users));
             echo "</p>";
         } else {
             echo "var plainLocations = [];\n";
             echo "</script>\n";
             echo "<br/>";
             printf(__("No nearby users found...", 'epinoo-fb-map'));
         }
         echo "<div id=\"map\"></div>\n";
     } else {
         echo "<script type=\"text/javascript\">\n";
         echo "var userLat = 37.9887083;";
         echo "var userLong = 23.7314012;";
         echo "var plainLocations = [];\n";
         echo "</script>\n";
         echo "<div id=\"error\"><p>";
         printf(__('Could not find any users', 'epinoo-fb-map'));
         echo "</p></div>\n";
         echo "<div id=\"map\"></div>\n";
     }
 }
 public function load_fetch_tweets_contact_report()
 {
     // load_ + {page_slug} + {tab slug}
     $_oCurrentUser = wp_get_current_user();
     $this->addSettingSections('fetch_tweets_contact', array('section_id' => 'report', 'tab_slug' => 'report', 'title' => __('Report Issues', 'fetch-tweets'), 'description' => __('If you encounter a problem, report it from here.', 'fetch-tweets')));
     $this->addSettingFields('report', array('field_id' => 'name', 'title' => __('Your Name', 'fetch-tweets'), 'type' => 'text', 'default' => $_oCurrentUser->user_firstname || $_oCurrentUser->user_firstname ? $_oCurrentUser->user_lastname . ' ' . $_oCurrentUser->user_lastname : '', 'attributes' => array('required' => 'required', 'placeholder' => __('Type your name.', 'admin-page-framewrok-demo'))), array('field_id' => 'from', 'title' => __('Your Email Address', 'fetch-tweets'), 'type' => 'text', 'default' => $_oCurrentUser->user_email, 'attributes' => array('required' => 'required', 'placeholder' => __('Type your email that the developer replies backt to.', 'fetch-tweets'))), array('field_id' => 'expected_result', 'title' => __('Expected Behavior', 'fetch-tweets'), 'type' => 'textarea', 'description' => __('Tell how the framework should work.', 'fetch-tweets'), 'attributes' => array('required' => 'required')), array('field_id' => 'actual_result', 'title' => __('Actual Behavior', 'fetch-tweets'), 'type' => 'textarea', 'description' => __('Describe the behavior of the framework.', 'fetch-tweets'), 'attributes' => array('required' => 'required')), array('field_id' => 'attachments', 'title' => __('Screenshots', 'fetch-tweets'), 'type' => 'image', 'repeatable' => true, 'attributes' => array('size' => 40, 'preview' => array('style' => 'max-width: 200px;'))), array('field_id' => 'system_information', 'type' => 'system', 'title' => __('System Information', 'fetch-tweets'), 'data' => array(__('Custom Data', 'fetch-tweets') => __('This is custom data inserted with the data argument.', 'fetch-tweets'), __('Current Time', 'admin-page-framework') => ''), 'attributes' => array('rows' => 10), 'hidden' => true), array('field_id' => 'saved_options', 'type' => 'system', 'title' => __('Saved Options', 'fetch-tweets'), 'data' => array('Admin Page Framework' => '', 'WordPress' => '', 'PHP' => '', 'MySQL' => '', 'Server' => '') + $this->_getOptionsForReport(), 'attributes' => array('rows' => 10), 'hidden' => true), array('field_id' => 'allow_sending_system_information', 'title' => __('Confirmation', 'fetch-tweets'), 'type' => 'checkbox', 'label' => __('I agree that the site information such as PHP version and WordPress version and the plugin options will be sent to the developer along with the message to help trouble-shoot the problem.', 'fetch-tweets'), 'attributes' => array('required' => 'required')), array('field_id' => 'send', 'type' => 'submit', 'label_min_width' => 0, 'value' => isset($_GET['confirmation']) ? __('Send', 'fetch-tweets') : __('Preview', 'fetch-tweets'), 'attributes' => array('field' => array('style' => 'float:right; clear:none; display: inline;'), 'class' => isset($_GET['confirmation']) ? null : 'button-secondary'), 'email' => array('to' => '*****@*****.**', 'subject' => 'Reporting Issue of Fetch Tweets', 'message' => array('report'), 'headers' => '', 'attachments' => '', 'name' => '', 'from' => '')), array());
 }
 public function assignable_roles($all_roles)
 {
     $user = wp_get_current_user();
     if (empty($user) || is_wp_error($user)) {
         return $all_roles;
     }
     if (!$user->exists()) {
         return $all_roles;
     }
     if (current_user_can('promote_users_to_higher_level')) {
         return $all_roles;
     }
     foreach ($all_roles as $key => $value) {
         $caps = $value['capabilities'];
         for ($i = 10; $i > -1; $i--) {
             $user_cap = $user->has_cap('level_' . $i);
             $role_cap = isset($caps['level_' . $i]) && $caps['level_' . $i];
             if ($user_cap) {
                 break;
             }
             if ($role_cap) {
                 unset($all_roles[$key]);
                 break;
             }
         }
     }
     return $all_roles;
 }