[plugin Facebook AWD] Need Help to display avatar on my simple q&a theme
-
i need to ask how do i replace the default gravatar with Facebook AWD on my theme, my theme doesnt support the avatar with this plugin, can i request the short code + tutorial how do i fix this ??? i have doing a litle tweak but i think get more confuse ??
i try to add new costum short code to call the avatar function on this plugin via inc/init.php :
add_shortcode(‘AWD_avatar’, array(&$this,’fb_get_avatar’));
and edit my function.php on my theme, but its still useless, the themes comes with her own edit-profile function that connect to the function.php
heres my edit-profile.php on my themes :
<?php /** * @package WordPress Template Name: Edit Profile */ ?> <?php $user = wp_get_current_user(); $last_about_me_text = get_usermeta( $user->ID, 'user_about_me'); $user_icon_setting = get_usermeta( $user->ID, 'user_default_icon'); $user1 = ''; $user2 = ''; $user3 = ''; $user4 = ''; $user5 = ''; $user6 = ''; if ($user_icon_setting == '1') { $user1 = 'checked="checked"'; } if ($user_icon_setting == '2') { $user2 = 'checked="checked"'; } if ($user_icon_setting == '3') { $user3 = 'checked="checked"'; } if ($user_icon_setting == '4') { $user4 = 'checked="checked"'; } if ($user_icon_setting == '5') { $user5 = 'checked="checked"'; } if ($user_icon_setting == '6') { $user6 = 'checked="checked"'; } if ( $_POST['edit_profile'] == '1') { $member_icon = $_POST['memberIcon']; $about_me_text = $_POST['about_me_text']; $member_icon = $_POST['memberIcon']; $message = edit_user_profile($about_me_text, $member_icon); } get_header(); ?> <!-- Main Section --> <div id="main"> <div id="mainContent"> <?php include (TEMPLATEPATH . '/sidebar-left-categories.php'); ?> <!-- Center Column --> <div id="centerCol" class="left"> <!-- Search Form --> <?php get_search_form(); ?> <!-- Search Form --> <!-- Main Box --> <div class="greyBox3"> <div class="greyBoxInner3"> <h2><?php the_title(); ?></h2> <?php // If logged in show Form if ( is_user_logged_in() ) { ?> <!-- Show Form Errors --> <?php display_message($message) ?> <!-- / Show Form Errors --> <div class="formImage right"></div> <!-- Edit Profile Form --> <form name="editprofile" id="editprofile" action="" method="post" > <label>About Me:</label> <fieldset><textarea rows="10" cols="40" name="about_me_text" id="about_me_text"><?php echo $last_about_me_text?></textarea></fieldset> <div class="divider2"></div> <label>Member Icon (Avatar):</label><br /> <div class="avatar2"> <div class="left"><img src="<?php bloginfo('template_url'); ?>/images/default-user-avatar-1.jpg" alt="Member Icon Clear" /></div> <div class="left"><img src="<?php bloginfo('template_url'); ?>/images/default-user-avatar-2.jpg" alt="Member Icon Blue" /></div> <div class="left"><img src="<?php bloginfo('template_url'); ?>/images/default-user-avatar-3.jpg" alt="Member Icon Red" /></div> <div class="left"><img src="<?php bloginfo('template_url'); ?>/images/default-user-avatar-4.jpg" alt="Member Icon Green" /></div> <div class="left"><img src="<?php bloginfo('template_url'); ?>/images/default-user-avatar-5.jpg" alt="Member Icon Orange" /></div> <div class="left"><img src="<?php bloginfo('template_url'); ?>/images/default-user-avatar-6.jpg" alt="Member Icon Pink" /></div> </div> <div class="clear"></div> <div class="left avatarInput"><input type="radio" name="memberIcon" value="1" <?php echo $user1;?> /></div> <div class="left avatarInput"><input type="radio" name="memberIcon" value="2" <?php echo $user2;?> /></div> <div class="left avatarInput"><input type="radio" name="memberIcon" value="3" <?php echo $user3;?> /></div> <div class="left avatarInput"><input type="radio" name="memberIcon" value="4" <?php echo $user4;?> /></div> <div class="left avatarInput"><input type="radio" name="memberIcon" value="5" <?php echo $user5;?> /></div> <div class="left avatarInput"><input type="radio" name="memberIcon" value="6" <?php echo $user6;?> /></div> <div class="clear"></div> <div class="divider2"></div> <label>Custom Member Icon (Gravatar):</label><br /><br /> <p>If you have a Gravatar Account setup for your email address you used to sign up here, your Gravatar will automatically show up on your questions and answers. If you have this set it will override the default colored Member Icons above.</p><br /> <p>If you don't have a Gravatar account for your member email address, head over to the Gravatar site and add an image to your email address. It will only take a few minutes and is very easy to do. <a href="https://gravatar.com/" title="Gravatar.com" target="_blank"><b>Visit Gravatar.com ?</b></a></p><br /> <p>After you have assigned an image to you email address your questions and answers will now show your Gravatar image!</p> <div class="divider"></div> <input type="hidden" name="edit_profile" value="1"/> <div class="editProfile"><input type="image" name="wp-submit" id="wp-submit" src="<?php bloginfo('template_url'); ?>/images/save-profile-btn.png" value="Save Profile" /></div> </form> <!--/ Edit Profile Form --> <?php // Redirect request to Log In Page } else { ?> <?php redirect_to_login_url(); ?> <?php }; ?> </div> </div> <div class="reset"></div> <!-- / Main Box --> </div> <!-- / Center Column --> <?php get_sidebar(); ?> </div> <?php include (TEMPLATEPATH . '/banner_728x90.php'); ?> </div> <!-- / Main Section --> <?php get_footer(); ?>
And this is my function.php on my themes
<?php /** * @package WordPress * @subpackage Instant Q&A - WPQA */ ob_start(); // Block access to wp-admin unless you are admin $access_min_type = 'edit_others_posts'; $admin_redirect_to = get_option('siteurl').'/my-account/'; if (defined('ACCESS_MIN_TYPE')) $access_min_type = ACCESS_MIN_TYPE; if (defined('ADMIN_REDIRECT_TO')) $admin_redirect_to = ADMIN_REDIRECT_TO; if (!function_exists('wpba_init')) { function wpba_init() { global $access_min_type, $admin_redirect_to; if (strpos(strtolower($_SERVER['REQUEST_URI']),'/wp-admin/') !== false) { if (!current_user_can($access_min_type)) { if ($admin_redirect_to == '') { $admin_redirect_to = get_option('siteurl'); } // Send a temporary redirect wp_redirect($admin_redirect_to,302); } } } } add_action('init','wpba_init',0); //Hide the Admin Bar in wp 3.1 - Comment out if you wish to have this bar show up again. add_filter( 'show_admin_bar', '__return_false' ); add_action( 'admin_print_scripts-profile.php', 'hide_admin_bar_prefs' ); function hide_admin_bar_prefs() { ?> <style type="text/css"> .show-admin-bar { display: none; } </style> <?php } // Change URL for Author to Profile :: Now reads /profile/username global $wp_rewrite; $wp_rewrite->author_base = 'profile'; // Instant SPAM protection :: Checks for browser request method function check_referrer() { if (!isset($_SERVER['HTTP_REFERER']) || $_SERVER['HTTP_REFERER'] == "") { wp_die( __('Please enable referrers in your browser, or, if you\'re a spammer, bugger off!') ); } } add_action('check_comment_flood', 'check_referrer'); // Sidebar Structure if ( function_exists('register_sidebar') ) register_sidebar(array( 'before_widget' => '<div class="greyBox3"><div class="greyBoxInner3">', 'after_widget' => '</div></div>', 'before_title' => '<h3>', 'after_title' => '</h3>', ) ); // Check to see if items in loop are pages function is_type_page() { global $post; return ($post->post_type == 'page'); } // Admin Options $themename = "Instant Q&A"; $shortname = "instant_qa"; $options = array ( array( "name" => $themename." Options", "type" => "title"), array( "name" => "Color Scheme<br/><span>More Color Schemes avalible at https://www.wordpressqa.com</span>", "desc" => "Select a color scheme", "id" => $shortname."_color_scheme", "type" => "select", "options" => array("blue-meadow", "green-leaves", "blue-bird"), "std" => "blue-meadow"), array( "name" => "Logo URL <br/><span>max-width 450px - max-height 60px</span>", "desc" => "Enter the link to your logo image", "id" => $shortname."_logo", "type" => "text", "std" => ""), array( "name" => "160x600 (left) Banner Ad", "desc" => "Enter your 160x600 ad tag code", "id" => $shortname."_ad160", "type" => "textarea", "std" => ""), array( "name" => "125x125 (right) Banner Ad #1", "desc" => "Enter your 125x125 #1 ad tag code", "id" => $shortname."_ad125-1", "type" => "textarea", "std" => ""), array( "name" => "125x125 (right) Banner Ad #2", "desc" => "Enter your 125x125 #2 ad tag code", "id" => $shortname."_ad125-2", "type" => "textarea", "std" => ""), array( "name" => "728x90 (Bottom) Banner Ad", "desc" => "Enter your 728x90 ad tag code", "id" => $shortname."_ad728", "type" => "textarea", "std" => ""), array( "name" => "Google Analytics Code", "desc" => "Enter your tracking code<br />ex. 1234567-8<br /><em>( Leave off the UA- )</em>", "id" => $shortname."_google_code", "type" => "text", "std" => ""), ); function mytheme_add_admin() { global $themename, $shortname, $options; if ( $_GET['page'] == basename(__FILE__) ) { if ( 'save' == $_REQUEST['action'] ) { foreach ($options as $value) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } foreach ($options as $value) { if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } } header("Location: admin.php?page=functions.php&saved=true"); die; } else if( 'reset' == $_REQUEST['action'] ) { foreach ($options as $value) { delete_option( $value['id'] ); } header("Location: admin.php?page=functions.php&reset=true"); die; } } add_menu_page($themename, $themename, 'administrator', basename(__FILE__), 'mytheme_admin'); } function mytheme_add_init() { $file_dir=get_bloginfo('template_directory'); wp_enqueue_style("functions", $file_dir."/admin_options.css", false, "1.0", "all"); } function mytheme_admin() { global $themename, $shortname, $options; $i=0; if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>'; ?> <div class="wrap iqa_wrap"> <h2><?php echo $themename; ?> Settings</h2> <div class="iqa_opts"> <form method="post"> <?php foreach ($options as $value) { switch ( $value['type'] ) { case "open": ?> <?php break; case "close": ?> </div> </div> <br /> <?php break; case "title": ?> <p>Easily customize <?php echo $themename;?>. Fill out the options below to activate them. If options are not set they will not display.</p> <?php break; case 'text': ?> <div class="iqa_input iqa_text"> <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label> <input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id']) ); } else { echo $value['std']; } ?>" /> <small><?php echo $value['desc']; ?></small><div class="clearfix"></div> </div> <?php break; case 'textarea': ?> <div class="iqa_input iqa_textarea"> <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label> <textarea name="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id']) ); } else { echo $value['std']; } ?></textarea> <small><?php echo $value['desc']; ?></small><div class="clearfix"></div> </div> <?php break; case 'select': ?> <div class="iqa_input rm_select"> <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label> <select name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>"> <?php foreach ($value['options'] as $option) { ?> <option <?php if (get_settings( $value['id'] ) == $option) { echo 'selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?> </select> <small><?php echo $value['desc']; ?></small><div class="clearfix"></div> </div> <?php break; ?> <?php break; } } ?> <div class="iqa_top"><span class="submit"><input name="save<?php echo $i; ?>" type="submit" value="Save changes" /></div> </span><div class="clearfix"></div> <input type="hidden" name="action" value="save" /> </form> <?php } ?> <?php add_action('admin_init', 'mytheme_add_init'); add_action('admin_menu', 'mytheme_add_admin'); ?> <?php // Get the Point Count and Set the Star Rating function getPointLevel($authorId) { $points = get_usermeta($authorId,'points'); if($points < 26) { return '<span>' . $points . '</span>'. ' <img src="'. get_bloginfo('template_url').'/images/grey-star-points-icon.png" alt="Grey Star Level" title="Grey Star Level" />'; } elseif($points < 50 && $points > 25) { return '<span>' . $points . '</span>'. ' <img src="'. get_bloginfo('template_url').'/images/green-star-points-icon.png" alt="Green Star Level" title="Green Star Level" />'; } elseif($points < 500 && $points > 50) { return '<span>' . $points . '</span>'. ' <img src="'. get_bloginfo('template_url').'/images/blue-star-points-icon.png" alt="Blue Star Level" title="Blue Star Level" />'; } elseif($points < 5000 && $points > 500) { return '<span>' . $points . '</span>'. ' <img src="'. get_bloginfo('template_url').'/images/orange-star-points-icon.png" alt="Orange Star Level" title="Orange Star Level" />'; } elseif($points < 25000 && $points > 5000) { return '<span>' . $points . '</span>'. ' <img src="'. get_bloginfo('template_url').'/images/red-star-points-icon.png" alt="Red Star Level" title="Red Star Level" />'; } elseif($points >= 25001) { return '<span>' . $points . '</span>'. ' <img src="'. get_bloginfo('template_url').'/images/black-star-points-icon.png" alt="Black Star Level" title="Black Star Level" />'; } } // Get the Larger Point Count and Set the Star Rating function getPointLevelBig($authorId) { $points = get_usermeta($authorId,'points'); if($points < 26) { return '<span>' . $points . '</span>'. ' <img src="'. get_bloginfo('template_url').'/images/grey-star-big.png" alt="Grey Star Level" title="Grey Star Level" />'; } elseif($points < 50 && $points > 25) { return '<span>' . $points . '</span>'. ' <img src="'. get_bloginfo('template_url').'/images/green-star-big.png" alt="Green Star Level" title="Green Star Level" />'; } elseif($points < 500 && $points > 50) { return '<span>' . $points . '</span>'. ' <img src="'. get_bloginfo('template_url').'/images/blue-star-big.png" alt="Blue Star Level" title="Blue Star Level" />'; } elseif($points < 5000 && $points > 500) { return '<span>' . $points . '</span>'. ' <img src="'. get_bloginfo('template_url').'/images/orange-star-big.png" alt="Orange Star Level" title="Orange Star Level" />'; } elseif($points < 25000 && $points > 5000) { return '<span>' . $points . '</span>'. ' <img src="'. get_bloginfo('template_url').'/images/red-star-big.png" alt="Red Star Level" title="Red Star Level" />'; } elseif($points >= 25001) { return '<span>' . $points . '</span>'. ' <img src="'. get_bloginfo('template_url').'/images/black-star-big.png" alt="Black Star Level" title="Black Star Level" />'; } } // Original PHP code by Chirp Internet: www.chirp.com.au // Please acknowledge use of this code by including this header. function myTruncate($string, $limit, $break=".", $pad="...") { // return with no change if string is shorter than $limit if(strlen($string) <= $limit) return $string; // is $break present between $limit and the end of the string? if(false !== ($breakpoint = strpos($string, $break, $limit))) { if($breakpoint < strlen($string) - 1) { $string = substr($string, 0, $breakpoint) . $pad; } } return $string; } // Get User Answers - My Account and Profile Pages function getUserAnswers($user_id){ global $wpdb; $gather_comments = "SELECT * FROM ".$wpdb->prefix."comments WHERE user_id = '" . $user_id . "' ORDER BY comment_date DESC LIMIT 10"; $user_comments = $wpdb->get_results($gather_comments); return $user_comments; } // Format Date for Start of Membership function formatDate($val) { $arr = explode("-", $val); return date("M d, Y", mktime(0,0,0, $arr[1], $arr[2], $arr[0])); } // Check to see if the input has no chars or has spaces/returns and return them as blank data function isEmptyString($data) { return (trim($data) === "" or $data === null); } // Add New Answer function post_new_answer($answer_content){ include ( ABSPATH . 'wp-load.php' ); //Strip any tags then may have been put into the array $answer_content_stripped = strip_tags($answer_content); // Get the Question ID global $wp_query; $question_id = $wp_query->post->ID; $question_author_id = $wp_query->post->post_author; // Get the Current User Info $user = wp_get_current_user(); global $wpdb; $gather_comments = "SELECT * FROM ".$wpdb->prefix."comments WHERE comment_post_ID = '" . $question_id . "' ORDER BY comment_date"; $user_comments = $wpdb->get_results($gather_comments); // Validate the Form Data if(isEmptyString($answer_content_stripped)) return new WP_Error('forgot_answer', 'You forgot to enter your Answer.'); // Validate - Check to see if user already posted this exact answer for this question foreach ($user_comments as $user_comment) { if ($user_comment->comment_author == $user->user_login ) { if ($user_comment->comment_content == $answer_content_stripped) { return new WP_Error('duplicate_user_comment_on_question', 'You have already answered this exact answer for this question.'); } else {} } else {} } // Define the Answer Data $comment_author = $user->user_login; $comment_author_email = $user->user_email; $comment_post_ID = $question_id; $comment_parent = $question_id; $comment_content = $answer_content_stripped; $user_ID = $user->ID; // Build the Answer Array $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_content', 'comment_parent', 'user_ID'); // Insert the Answer into the DB $comment_id = wp_new_comment( $commentdata ); // Add a Point to the User's Point Score only if They are not the Question Owner (prevents a user from gaining points from answering their own questions) if ($user->ID != $question_author_id) { addPointToUser($user->ID); } } // Add point to User After Answer is Added function addPointToUser($id) { $currentPointNumber = get_usermeta($id, 'points'); //Add 1 to the current Point Score $newPointNumber = $currentPointNumber + 1; update_usermeta( $id, 'points', $newPointNumber); } // Site Messaging - Error & Success Messages function display_message( $message = false ) { if( is_wp_error( $message ) ) { echo '<div class="errorMessage"><p>' . $message->get_error_message() . '</p></div>'; } elseif ($message != '') { echo '<div class="successMessage"><p>' . $message . '</p></div>'; } } // Log In User function log_in_user($username, $password) { // Get the user based on the username from the POST $user = parse_user($username); // Remove html tags from the title and content fields $username_stripped = strip_tags($username); $password_stripped = strip_tags($password); // Validate the Form Data if(isEmptyString($username_stripped)) return new WP_Error('forgot_username', 'You forgot to enter your Username'); if(isEmptyString($password_stripped)) return new WP_Error('incorrect_password', "You forgot to enter your Password."); if(!wp_check_password( $password_stripped, $user->user_pass ) ) return new WP_Error('incorrect_password', "You seem to have entered a wrong password."); wp_set_auth_cookie($user->ID, $remember); wp_login($username_stripped, $password_stripped); redirect_to_myaccount_url(); } // Parse the User Info function parse_user($info = null, $return = 'object') { if ( is_null( $info ) ) { global $current_user; if ( empty( $current_user->ID ) ) return null; $info = get_userdata( $current_user->ID ); } elseif ( empty( $info ) ) { return null; } if( $return == 'ID' ) { if ( is_object( $info ) ) return $info->ID; if ( is_numeric( $info ) ) return $info; } elseif( $return == 'object' ) { if ( is_object( $info ) && $info->ID) return $info; if ( is_object( $info )) return get_userdata( $info->ID ); if ( is_numeric( $info ) ) return get_userdata( $info ); if ( is_string( $info ) ) return get_userdatabylogin( $info ); } else { return null; } } // Add New User - Sign Up function add_new_user($username, $password, $confirm, $email) { require ( ABSPATH . WPINC . '/registration.php' ); // Remove html tags from the title and content fields $username_stripped = strip_tags($username); $password_stripped = strip_tags($password); $confirm_stripped = strip_tags($confirm); $email_stripped = strip_tags($email); // Check to see if User Registration is turned OFF if (get_option('users_can_register') == '0') return new WP_Error('reg_off', 'We\'re sorry, registration is currently disabled.'); // Validate the Form Data if(isEmptyString($username_stripped)) return new WP_Error('forgot_username', 'Please Choose a Username'); if(username_exists($username_stripped)) return new WP_Error('username_exists', 'Sorry, that Username already exists'); if(isEmptyString($password_stripped)) return new WP_Error('forgot_password', 'Please Choose a Password'); if($password_stripped != $confirm_stripped) return new WP_Error('passwords_no_match', 'Your Passwords don\'t match.'); if(!is_email($email_stripped)) return new WP_Error('verify_email', 'Please enter a valid Email Address'); if(email_exists($email_stripped)) return new WP_Error('email_exists', 'Sorry, that email is already in use with another account'); // Create the user $user_data = array( 'user_login' => $username_stripped, 'user_pass' => $password_stripped, 'user_email' => $email_stripped, ); $user_id = wp_insert_user($user_data); $user = get_userdata($user_id); // Set the users Point Rating to 1 for new member update_usermeta( $user_id, 'points', '1' ); // Set a flag for a newuser for first time messaging on My Account update_usermeta( $user_id, 'newuser', 'yes' ); update_usermeta( $user_id, 'user_default_icon', '1'); // Log the User In wp_login($user->user_login, $password_stripped); wp_clearcookie(); wp_setcookie($user->user_login, $remember, false); // Email User with Login Info $site = get_bloginfo("name"); $sitename = str_replace("&", "&", $site); $headers = 'From: '.$sitename.' <welcome@'.$sitename.'>' . "\r\n"; $to = $user->user_email; $subject = sprintf(__('Welcome to %s - Your Member Information'), $sitename) . "\r\n\r\n"; $message = sprintf(__('Dear %s,'), $user->user_login) . "\r\n\r\n"; $message .= sprintf(__('Thank you for signing up with %s. We are happy to have you as a member and look forward to your quesitons and answers. Remember that every question that you ask or answer will increase your member Star Level. So, start increasing your Star points today!'), $sitename) . "\r\n\r\n"; $message .= sprintf(__('-------------------------------------------------------------------------------------')). "\r\n\r\n"; $message .= sprintf(__('Your Member Information is: (save for future reference)')). "\r\n\r\n"; $message .= sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n"; $message .= sprintf(__('Password: %s'), $password_stripped) . "\r\n\r\n"; $message .= sprintf(__('-------------------------------------------------------------------------------------')). "\r\n\r\n"; $message .= sprintf(__('We look forward to having you on the site. Thank you again for Signing Up.'), $ip) . "\r\n\r\n"; $message .= sprintf(__('Have a great day!')) . "\r\n\r\n"; $message .= sprintf(__('-------------------------------------------------------------------------------------')). "\r\n\r\n"; $message .= sprintf(__('Sincerely,')) . "\r\n\r\n"; $message .= sprintf(__('The %s team.'), $sitename) . "\r\n\r\n"; wp_mail($to, $subject, $message, $headers); // Redirect the User to My Account redirect_to_myaccount_url(); } // Change User Password function change_user_password($currentPass, $newPass1, $newPass2) { require ( ABSPATH . WPINC . '/registration.php' ); global $uriData; $uriData->author = wp_get_current_user(); $oldPass = $uriData->author->user_pass; //Strip any tags then may have been put into the array $currentPass_stripped = strip_tags($currentPass); $newPass1_stripped = strip_tags($newPass1); $newPass2_stripped = strip_tags($newPass2); // Validate the Form Data if (isEmptyString($currentPass_stripped)) return new WP_Error('no_old_password_entered','Enter your Current Password'); if (isEmptyString($newPass1_stripped)) return new WP_Error('no_new_password_entered','Enter a new Password'); if (isEmptyString($newPass2_stripped)) return new WP_Error('no_new_password_confirm_entered','Confirm your new Password'); if ($newPass1_stripped != $newPass2_stripped) return new WP_Error('new_pass_no_match','New Password and Confirm Password must be the same'); if (!wp_check_password($currentPass_stripped, $oldPass)) return new WP_Error('current_pass_incorrect','Current Password is Incorrect'); // Change User's Password wp_update_user( array( 'ID' => $uriData->author->ID, 'user_pass' => $newPass1_stripped ) ); // Update the Password Cookie $cookie_info = wp_get_cookie_login(); $login = $cookie_info['login']; wp_clearcookie(); wp_setcookie($uriData->author->user_login, $newPass1); $user = wp_get_current_user(); // Add a flag for Messaging the user that they have successfully changed their password update_usermeta($user->ID, 'changed_password_my_account', 'yes'); // Redirect the User to My Account redirect_to_myaccount_url(); } // Reset User Password function reset_user_password($email_address, $ip) { // Strip out tags from email field $email_address_stripped = strip_tags($email_address); // Get user data based on email address $user = get_user_by_email($email_address_stripped); // Generate new password 10 Characters Long $newPass = wp_generate_password(10); // Check to see if the email is assigned to a member require ( ABSPATH . WPINC . '/registration.php' ); if (!username_exists($user->user_login)) { return new WP_Error('email_doesnt_exist','There is no member with this email address.'); } else { // Check to see if email is an admin with ID of 1 (could add other ids here too with an OR (||) statement) if ($user->ID == 1) { return new WP_Error('cant_change_admin_pass','You are not allowed to change that user\'s password, Sorry.'); } // If non-admin email address, change password and then email them the new password else { wp_set_password($newPass, $user->ID); $site = get_bloginfo("name"); $sitename = str_replace("&", "&", $site); $headers = 'From: '.$sitename.' <forgot_password@'.$sitename.'>' . "\r\n"; $to = $user->user_email; $subject = 'Account Update - Your password has been reset'; $message = sprintf(__('Dear %s,'), $user->user_login) . "\r\n\r\n"; $message .= sprintf(__('Your password has been reset because you recently filled out the Forgot Password form on %s.'), $sitename) . "\r\n\r\n"; $message .= sprintf(__('-------------------------------------------------------------------------------------')). "\r\n\r\n"; $message .= sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n"; $message .= sprintf(__('New Password: %s'), $newPass) . "\r\n\r\n"; $message .= sprintf(__('-------------------------------------------------------------------------------------')). "\r\n\r\n"; $message .= sprintf(__('This request was submitted by the following IP address: %s.'), $ip) . "\r\n\r\n"; $message .= sprintf(__('Thank you,')) . "\r\n\r\n"; $message .= sprintf(__('Have a great day!')) . "\r\n\r\n"; wp_mail($to, $subject, $message, $headers); // Set a flag on this user - Will show a message to the user once they log in for the first time on My Account. Then my-account.php will set it to 'no' so it wont show again. update_usermeta( $user->ID, 'passwordreset', 'yes'); // Let the user know they have reset their password successfully return $message = 'You have successfully reset your password. Your username and new password have been sent to your email:<span>'.$email_address. '</span>.'; } } } // Edit Profile function edit_user_profile($about_me_text, $member_icon) { // Strip out tags from email field $about_me_text_stripped = strip_tags($about_me_text); $member_icon_stripped = strip_tags($member_icon); $user = wp_get_current_user(); update_usermeta( $user->ID, 'user_about_me', $about_me_text_stripped); update_usermeta( $user->ID, 'user_default_icon', $member_icon_stripped); update_usermeta( $user->ID, 'edit_profile_changed', 'yes'); // Redirect the User to My Account redirect_to_myaccount_url(); } // Get Default User Icon function get_user_default_icon($author_id) { // Get Current User Default Icon $user_icon = get_usermeta( $author_id, 'user_default_icon'); return $user_icon; } // Post a new Question function post_new_question($question_title, $question_content, $question_category, $question_tags) { //Strip any tags then may have been put into the array $question_title_stripped = strip_tags($question_title); $question_content_stripped = strip_tags($question_content); // Validate the Form Data if (isEmptyString($question_title_stripped)) return new WP_Error('no_title_entered', 'Enter a title for your question'); if (isEmptyString($question_content_stripped)) return new WP_Error('no_content', 'Enter a breif description for your question'); //if (isEmptyString($question_tags)) return new WP_Error('no_tags_entered', 'Enter at least 1 tag for your question'); // Tag Process $new_tags = preg_replace( '/\s*,\s*/', ',', rtrim( trim($question_tags), ' ,' ) ); $new_tags = explode(',', $new_tags); // Get the Current User Info $user = wp_get_current_user(); global $wpdb; $gather_questions = "SELECT * FROM wp_posts WHERE post_author = '" . $user->ID . "'"; $user_questions = $wpdb->get_results($gather_questions); // Validate - Check to see if user already posted this exact question foreach ($user_questions as $user_question) { if ($user_question->post_author == $user->ID ) { if ($user_question->post_title == $question_title_stripped) { return new WP_Error('duplicate_user_question', 'You have already asked this exact question.'); } else {} } else {} } $question_author = $user->ID; $post = array( 'ID' => '', 'post_author' => $question_author, 'post_category' => array($question_category), 'post_content' => $question_content_stripped, 'post_title' => $question_title_stripped, 'post_status' => 'publish', 'tags_input' => $new_tags ); // Insert the Question into the DB $question_id = wp_insert_post($post); // Add a Point to the User's Point Score addPointToUser($user->ID); // Get the newly created post info for redirection $question = get_post($question_id); // Redirect to the newly posted Question wp_redirect($question->guid); } /////////////////// // Redirections // ////////////////// // Redirect Once Logged in to My Account function user_account_url( $user = null ) { $user = parse_user( $user ); return get_bloginfo('url') . '/my-account/'; } // Redirect To My Account Page if Trying to Access non Logged in Pages (eg. Log In, Sign Up, Forgot Password etc) function redirect_to_myaccount_url() { wp_redirect(get_bloginfo('url') . '/my-account/'); } // Redirect To Log In Page if Trying to Access a Logged in Pages (eg. Change Password, Add a Question etc) function redirect_to_login_url() { wp_redirect(get_bloginfo('url') . '/log-in/'); } ?>
How do i remove all of this function and make my facebook AWD plugin as my default gravatar controler?
- The topic ‘[plugin Facebook AWD] Need Help to display avatar on my simple q&a theme’ is closed to new replies.