Bhavesh Patel
Forum Replies Created
-
Forum: Hacks
In reply to: Import users from non-wordpress databaseHello Jan Dembowski,
Your are right. My intention was not bad and thanks for understanding it.
Actually i don’t know about this rule. And surely this will not happen again.
Thanks Jan Dembowski.Forum: Hacks
In reply to: Import users from non-wordpress databaseHi iamdanieljs,
You can create your own script to handle this task. Its very simple task though.
You have to create custom database connection for fetching data from eventbooking_clients table
Create one array namely users to get users data from eventbooking_clients table.
Close this database connection after getting all the users in array.//For Example
foreach($users as $user){ $user_id = username_exists( $user['user_name'] ); if ( !$user_id and email_exists($user['mail']) == false ) { $random_password = wp_generate_password( $length=12, $include_standard_special_chars=false ); $user_id = wp_create_user($user['user_name'], $random_password, $user['email']); } else { $random_password = __('User already exists. Password inherited.'); } }
If you want to do this task on regular basis(Example:execute a script on daily basis) than you can create one Cron job for it.
Also you can manage this by inserting one new column like last_updated date in eventbooking_clients table and fetch only required users.Forum: Hacks
In reply to: How to store API login informationrebeccahbl-
You can do it in two ways.
1. Keeping detail in option table. But before saving your detail you may encrypt it using any Encryption method .Create one algorithm(that will be found easily on google) that will help you to secure your login detail.
For example
To add into Option table.//Once you add this into database.You may remove this below line. add_option( 'username', 'Your encrypted username');
To get from option table
get_option( $option, $default );
2. place your detail in config file.
Forum: Hacks
In reply to: How to call php code if in pagination other than page 1Glad to hear from you.
Love this below sentence.
I try to explain again, so other people who have this problem can learn from this ??
Please mark this topic as Resolved
Forum: Hacks
In reply to: Getting last role when counting user with certain rolesSince you can do this with CSS as well.
For example
If you have below list<ul class="ul_class"> <li><a title="" href=""></a></li> <li><a title="" href=""></a></li> <li><a title="" href=""></a></li> <li><a title="" href=""></a></li> </ul>
So class can be added like this.
.ul_class:last-of-type { //Set your style over here. }
Forum: Hacks
In reply to: How to call php code if in pagination other than page 1crovinca –
I don’t understand your whole problem.
Still i’d like to suggest as per my understanding.seems you should use in_array() function to make your condition as per your requirement.
For exmaple:
$count = array(2,5,8); /*It may change*/ if (in_array($paged, $count)) { //Success.show your ads here }
If the above is not pertinent, feel free to ignore it. And do let me know more about your problem.
Forum: Hacks
In reply to: Set uploaded image or image url as featured imageimmoon-
I think you should post only required code only.
click on this link.It will surely resolve your problem.And still you need more help than let me know.
Forum: Hacks
In reply to: Custom post creation with user creationanjanap-
It’s very simple job.
After successful creation of user you can apply below code.
// Create post object $my_post = array( 'post_title' => 'Your Post title', 'post_content' => 'Your Post Content.', 'post_status' => 'publish', 'post_author' => 1, /* You may setup your created user id if he has capabilities of doing so. */ 'post_category' => array(1) /* As per requirement */ ); $post_id = wp_insert_post( $my_post );
By executing wp_insert_post,your post will be created.
Now you have only one thing remaining – User’s Metadata.
Here you may use add_post_meta or update_post_meta.
add_post_meta($post_id, 'address', 'Ghatlodiya,Patidar Road, Ahmedabad'); add_post_meta($post_id, 'country', 'INDIA');
Forum: Hacks
In reply to: Force "Link To" as "None" In MediaYou can do this by updating option image_default_link_type
Place this in your theme’s functions.php file.
function change_imgage_default_link() { //You may change it media,file,post... update_option('image_default_link_type','none'); } add_action('after_setup_theme', 'change_imgage_default_link');
Forum: Hacks
In reply to: unset(…) documentation for removing default fieldsHello matthewtvogel,
I have done this tactic using jQuery in my one of the project.
You can place below code in your plugin.
<?php add_action('admin_head','hide_personal_options'); function hide_personal_options() { ?> <script type="text/javascript"> jQuery(document).ready(function($) { $("#email").parent().parent().remove(); // Add id of email or whatever you want to hide $(".user-admin-color-wrap").hide(); //To disable Admin Color Scheme }); </script> <?php }
I have searched lot on google but nothing found helpful for the same till now.
Let me know if this helps you.
Forum: Hacks
In reply to: before_delete_post – problemsTo display error message on the same page follow below tactic.
add_action( 'before_delete_post', 'function_to_run_on_post_trash' ); function function_to_run_on_post_trash( $post_id ){ if(connection_not_found){ /* Or Anything similar */ wp_redirect( admin_url('edit.php?post_status=trash&post_type=post&my_unique_flag=error')); exit; } } /*Handle GET parameter*/ if(isset($_GET['my_unique_flag'])){ /*MUST be unique*/ if($_GET['my_unique_flag'] == 'error'){ echo '<div class="error"> <p>Dear user, You are not allowed to do this...!! :)</p> </div>'; } }
Put this below code in both the function
if(connection_not_found){ /* Or Anything similar */ wp_redirect( admin_url('edit.php?post_status=trash&post_type=post&my_unique_flag=error')); exit; }
Also change wp_redirect url as per your edit,delete action.
If above code does not work as per your requirement than do let me know.
Have a good day… ??
Forum: Hacks
In reply to: before_delete_post – problemsBelow are the ways you can tell wordpress like “stop what you are doing”
1. To control Trash action (on All Page/Published post page)
add_action( 'wp_trash_post', 'function_to_run_on_post_trash' ); function function_to_run_on_post_trash( $post_id ){ //Check Your connection if found anything wrong then execute below code //f.e if(connection_not_found){ echo '<div class="error"> <p>Sorry you can't delete blog rightnow</p> </div>'; exit; /* MUST */ } }
2. To control Permanently Delete action (on Trash Page)
add_action( 'before_delete_post', 'func_to_run_on_permanently_delete' ); function func_to_run_on_permanently_delete( $post_id ){ //Check Your connection //if found anything wrong then execute below code //f.e if(connection_not_found){ /* Or Anything similar */ echo '<div class="error"> <p>Sorry you can't delete blog Permanently rightnow</p> </div>'; exit; /* MUST */ } }
Make Your error message stylish and will work like charm.
Forum: Hacks
In reply to: How do I use a post(Custom post-type) as front page?Follow below link.
Forum: Hacks
In reply to: before_delete_post – problemsPlease check trash_post
Run actions on post, page, or custom post type is about to be trashed. The post ID is passed to the action hook.
add_action( 'wp_trash_post', 'function_to_run_on_post_trash' ); function function_to_run_on_post_trash( $post_id ){ $one = 1; $two = 2; $result = $one + $two; }
To add hook before inserting post to DB, you can use pre_post_update
Forum: Hacks
In reply to: post_not_inHello ZaydB,
There is no ‘post_not_in’ in get_posts function.
I recommend WP_Query in place of get_posts.