Category Archives: Wordpress Plugins

dsIDXpress not functioning properly in Thesis 2

dsIDXpress is a plugin for wordpress that gives IDX functionality to wordpress based site.

It allows visitors to search and browse available properties in your MLS.

Search engine will index properties from MLS on the website.

dsIDXpress works with Thesis 1.x series, but recently did a site on Thesis 2. Widgets, shortcodes etc will work without any issues.

But the page that displays the details of single property is not working. It just shows the contents of home page.

dsIDXpress is not recognizing any templates in Thesis 2.

Hope the plugin developer and thesis theme developer share their knowledge and figure out a fix / solution.

WordPress Plugin to change Display name as first name and capital letter of second name



Please update!';
if (version_compare($wp_version,"2.5","<")) { exit ($exit_msg); } function sd_new_login_filter ($login) { /* Don't do anything to login, just see if already in database.*/ global $wpdb, $sd_is_new_login; $id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$login'");
$sd_is_new_login = (isset($id)) ? false : true;
return $login;
}

function sd_substitute_displayname_filter ($display_name) {
global $sd_is_new_login;

if ($sd_is_new_login){
$first_letter = substr($_POST['last_name'], 0, 1);
$display_name = $_POST['first_name']." ".$first_letter;
}
return $display_name;
}
add_filter('pre_user_login', 'sd_new_login_filter');
add_filter('pre_user_display_name', 'sd_substitute_displayname_filter');
add_action ('admin_head','make_display_name_f_name_last_name');
function make_display_name_f_name_last_name(){

$users = get_users(array('fields'=>'all'));

foreach($users as $user){
$user = get_userdata($user->ID);
$firstletter = substr($user->last_name, 0, 1);
$display_name = $user->first_name . " " . $firstletter;

if($display_name!=' ') wp_update_user( array ('ID' => $user->ID, 'display_name' => $display_name) );
else wp_update_user( array ('ID' => $user->ID, 'display_name' => $user->display_login) );

if($user->display_name == '')
wp_update_user( array ('ID' => $user->ID, 'display_name' => $user->display_login) );
}
}

?>

Done with the help of following threads:
1. http://stackoverflow.com/questions/9326315/wordpress-change-default-display-name-publicy-as-for-all-existing-users
2. http://wordpress.org/support/topic/change-default-display-name-1

Some helpful information for writing a plugin

I am sharing 2 simple plugins I did, so it will be helpful for new plugin writers.

My client wanted to add an award section. That is, he wanted to assign an award for some post and display it in the front end under the title of the post. Each award has an image also.

So first he needs to create the awards. For that I wrote this plugin.

Now I have to display these awards when editing a post/ adding a new post.

For that I used the following plugin: Adding custom box

This plugin will save the award id as post meta. Later in the theme page we can call the post meta and display the award.

How to allow users to post only in some categories: wordpress

The following code will be useful if you want to allow users to post only in some categories.


function restrict_categories($categories) { 
// If we are in the new/edit post page and not an admin, then restrict the categories
$onPostPage = (strpos($_SERVER['PHP_SELF'], 'post.php') || strpos($_SERVER['PHP_SELF'], 'post-new.php'));
if (is_admin() && $onPostPage && !current_user_can('level_10')) {
$size = count($categories);
for ($i = 0; $i < $size; $i++) {			 			if ($categories[$i]->slug != 'user-created-articles' && $categories[$i]->slug != 'user-created-content' && $categories[$i]->slug != 'user-created-disagreements'&& $categories[$i]->slug != 'user-created-reviews')
unset($categories[$i]);
}
}
return $categories;
}
add_filter('get_terms', 'restrict_categories');

In the above code it checks the category slug. Admin can post in any categories, but other users can post only in the categories, where slug is either “user-created-articles” or “user-created-articles” or “user-created-disagreements” or “user-created-reviews”