WHSajid
Forum Replies Created
-
Forum: Plugins
In reply to: [WPBruiser {no- Captcha anti-Spam}] WP DB ErrorHi,
Thank you for the quick fix. Once again, this is an amazing plugin. It’s easy on the server and works as advertised, without getting in the way. Great work guys, glad I could be of help.
Cheers,
Forum: Plugins
In reply to: [WP RSS Multi Importer] Can I import categories/tags/authors from the feed?No worries. Glad I could be of help. I’m sure you can make it even better.
Forum: Plugins
In reply to: [WP RSS Multi Importer] Can I import categories/tags/authors from the feed?For anyone who stumbles upon this, there’s an issue in the code I posted earlier. The following code is the correct one and does everything I initially wanted.
- Takes the post Author Names from the feed and adds them as real Authors.
- Takes the Category Names from the feed and creates (if they don’t exist) the categories and assigns them to the posts.
For those developers among you, the plugin is built using Simple Pie, so you should be able to figure out what the code means. I hope these features are added in the future. This is an awesome plugin and provides a lot of features only provided by paid plugins. Great work Allen. Cheers.
//Adds the Category names to the Items array. $myarray[] = array("rssCatName"=>$rssCatName); //Gets the Category names from the RSS Feed. $rssCatName = array(); foreach ($item->get_categories() as $category) { $rssCatName[] = $category->get_label(); } // Checks to see if the Categories exist and adds the ones that dont. foreach ($items["rssCatName"] as $category) { $termEx = term_exists($category, 'category'); if ($termEx == false) { wp_create_category(ucwords($category)); } } //Assigns the new Categories to the post. $rssCatIDList[] = array(); foreach ($items["rssCatName"] as $category) { $rssCatIDList[] = get_cat_ID( $category ); } $post['post_category'] = $rssCatIDList; //Checks to see if the Authors exist, creates the ones that dont and assigns the correct Authors to the imported posts. $user_id = username_exists( $items["myAuthor"] ); if ( $user_id == false ) { $random_password = wp_generate_password( $length=12, $include_standard_special_chars=false ); $userdata = array( 'user_login' => $items["myAuthor"], 'user_pass' => $random_password, 'role' => 'author' ); $user_id = wp_insert_user( $userdata ); $addeduser = get_user_by( 'login', $items["myAuthor"] ); $post['post_author'] = $addeduser->id; }
Forum: Plugins
In reply to: [WP RSS Multi Importer] Can I import categories/tags/authors from the feed?Hi, thanx but by importing the Author I meant importing it into the post meta as the Author. Right now, all it does is include a “By: ” line in the post content. Obviously, that can have some unwanted effects on the layout.
Forum: Plugins
In reply to: [WP RSS Multi Importer] Can I import categories/tags/authors from the feed?Here’s for anyone else looking for the same thing. The code (should go somewhere around line 745 of import_posts.php) may have some issues, so don’t use it unless you know what you’re doing.
The following will:
1. Check if the author from the feed exist in the WP database.
2. Create the author if he/she doesn’t exist. (With a random password, and Author roles.)
3. Set the author to the post.if(!empty($items["myAuthor"]) && $addAuthor==1){ $user_id = username_exists( $items["myAuthor"] ); if ( !$user_id == false ) { $random_password = wp_generate_password( $length=12, $include_standard_special_chars=false ); $userdata = array( 'user_login' => $items["myAuthor"], 'user_pass' => $random_password, 'role' => 'author' ); $user_id = wp_insert_user( $userdata ); } }
Would appreciate if someone could improve this and also if someone could provide an easy solution to the category issue.