update_user_meta on registration but only for default role type

Here is what you need to do: function set_user_rcp_default_subscriber($user_id) { $user = new WP_User( $user_id ); foreach( $user->roles as $role ) { if ( $role === ‘subscriber’ ) { update_user_meta( $user_id, ‘wp_user_level’, ‘0’ ); update_user_meta( $user_id, ‘rcp_subscription_level’, ‘1’ ); update_user_meta( $user_id, ‘rcp_status’, ‘active’ ); update_user_meta( $user_id, ‘rcp_expiration’, ‘2014-06-30’ ); } } } add_action(“user_register”, “set_user_rcp_default_subscriber”, 10, … Read more

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