Add meta tag to search results

Well I am asuming you want to amend the <title> tag? Add this in functions.php add_filter(‘wp_title’, ‘my_custom_page_title’); function my_custom_page_title($title) { global $s; if( isset($_REQUEST[‘author_name’]) && is_search() ) { $title=”Search Results for “.$s.’ from author ‘.$_REQUEST[‘author_name’]; } return $title; } If $s returns blank replace that with $_REQUEST[‘s’]

How to access User meta data within a plugin

Please look at the last two lines of code. I am trying to print the id of the user. It works when used in the theme files but not inside the plugin. //Test Usermeta $user = get_userdatabylogin(‘vijay’); echo $user->ID; // prints the id of the user; In PHP, you cannot (normally) execute a user function … Read more

Validate user meta and redirect

Here is how I would do it: function save_extra_user_profile_fields( $user_id ) { if (!isset($_POST[‘address’]) || empty($_POST[‘address’])) { // this field was not set or was empty // do your action wp_redirect( home_url() ); // or profile page exit; } else { // field was set and contains a value // do your action update_user_meta( $user_id, … Read more

Creating Custom user type just like custom post

Well, Roles are in many ways custom user types and you can add meta fields specific to roles. For example… function is_my_user_role($id = null) { global $profileuser; if (empty($profile) && !empty($id)) $profileuser = get_user_to_edit($id); return (in_array(‘myrole’,$profileuser->roles)) ? true : false; } function my_user_fields($profileuser) { if (!is_my_user_role()) return false; // HTML for the fields } add_action(‘show_user_profile’, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)