isitegate
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Can’t create a new page in wordpressHi there,
In case someone faces this in future, here what worked in my case:
In fact, there were many rows with the same ID , i had to create new table , copy the old table rows with auto increment option, remove the old table then rename the new table to the old table’s name. that did the trick.
Thanks all.
Forum: Fixing WordPress
In reply to: Can’t create a new page in wordpressThe code i used to remove the not optimised pages is here:
<?php // Read ral-opt-slugs.txt file and store slugs in array $slugs = file('ral-opt-slugs.txt', FILE_IGNORE_NEW_LINES); // Connect to database $servername = "localhost"; $username = "root"; $password = ""; $dbname = "test"; $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } // Ping the MySQL server to ensure the connection is still alive if (!mysqli_ping($conn)) { die("Connection lost."); } // Delete pages that are not in the list of slugs and not reserved $sql = "SELECT * FROM wp_posts WHERE post_type = 'page' AND post_name NOT IN ('" . implode("', '", $slugs) . "') AND post_name NOT LIKE 'media%' AND post_name NOT LIKE 'plugins%' AND post_name NOT LIKE 'themes%'"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { while ($row = mysqli_fetch_assoc($result)) { $id = $row['ID']; $sql = "DELETE FROM wp_postmeta WHERE post_id = '$id'"; mysqli_query($conn, $sql); $sql = "DELETE FROM wp_posts WHERE ID = '$id'"; mysqli_query($conn, $sql); echo "Deleted page with slug: " . $row['post_name'] . "\n"; } } else { echo "No pages found for deletion.\n"; } // Close database connection mysqli_close($conn); ?>- This reply was modified 3 years, 2 months ago by isitegate.
Forum: Fixing WordPress
In reply to: Homepage returns 404 for non-logged usersResolved
Forum: Fixing WordPress
In reply to: Homepage returns 404 for non-logged usersThank you for the reply.
sorry for wasting your time but it was my fault as previously I set the page to private not public.
However, your reply gave me the hint as when I checked the reading settings i couldn’t find the homepage in the list of pages there so realised there is something wrong and remembered.
Sorted now.
Thanks again
Worked fine,
Thank you very muchHi Suman,
That’s what I have done in the above code, can you please check it?Regards
Perfect.
Thank you very much.So the final code is :
/* USER REGISTRATION PLUGIN => INCLUDE USER ID */ add_filter('user_registration_add_smart_tags','ur_add_source_in_admin_email',10, 2 ); function ur_add_source_in_admin_email($default_values,$email){ $user = get_user_by( 'email', $email ); $form_id = ur_get_form_id_by_userid( $user->ID ); $form_post = get_post( $form_id ); $post_title = $form_post->post_title; $current_user = wp_get_current_user(); $custom_default_values = array( 'ur_user_id' => $user->ID, 'ur_user_first_name' => $current_user->user_firstname, 'ur_user_last_name' => $current_user->user_lastname, ); $default_values = array_merge($default_values,$custom_default_values); return $default_values; } add_filter('user_registration_smart_tags','ur_add_source_in_admin_emails',10, 1 ); function ur_add_source_in_admin_emails($smart_tags){ $custom_smart_tags = array( '{{ur_user_id}}','{{ur_user_first_name}}','{{ur_user_last_name}}' ); $smart_tags = array_merge($smart_tags,$custom_smart_tags); return $smart_tags; }but as I mentioned the first and last names are empty at the moment, how can i get it to work, please?
Thank you
Thanks a lot, Armit.
Yes of course, well deserved.Now I’m trying to add the user’s first and last name similarly, can you please advise what is wrong with my code? the first and last names are empty at the moment:
.......................... .......................... $current_user = wp_get_current_user();$custom_default_values = array(
‘ur_user_id’ => $user->ID,
‘ur_user_first_name’ => $current_user->user_firstname,
‘ur_user_last_name’ => $current_user->user_lastname,
);
………………………………
………………………………
$custom_smart_tags = array(
‘{{ur_user_id}}’,'{{ur_user_first_name}}’,'{{ur_user_last_name}}’
);`Hi Suman,
Thank you for the reply and I appreciate it very much.Suman, for now, can’t you give me any snippet to add, please?
If you don’t mind, I’ll share my attempt with you and you can tell me what am I missing:
(Please):1- I have added the placeholder for {{user_id}} in the “placeholder-instructions.php”:
<tr> <td> {{user_id}}<br> <?php echo __( 'Use this placeholder to display user id', 'send-users-email' ); ?> </td> </tr>I now can see the new placeholder on the backend.
2- I have amended 6 lines in the “class-send-users-email-admin.php”:
On lines: 240-243 & 373-376:$user_id = get_current_user_id(); // Replace placeholder with user content $email_body = $this->replace_placeholder( $email_body, $username, $display_name, $first_name, $last_name, $user_email, $user_id );Then on lines: 556-570 the last function there as follwo:
private function replace_placeholder( $email_body, $username, $display_name, $first_name, $last_name, $user_email, $user_id ) { $email_body = str_replace( '{{username}}', $username, $email_body ); $email_body = str_replace( '{{user_display_name}}', $display_name, $email_body ); $email_body = str_replace( '{{user_first_name}}', $first_name, $email_body ); $email_body = str_replace( '{{user_last_name}}', $last_name, $email_body ); $email_body = str_replace( '{{user_email}}', $user_email, $email_body ); $email_body = str_replace( '{{user_id}}', $user_id, $email_body ); return nl2br( $email_body ); }I hope you will give it a few minutes and paste you feedback here so i can get it done.
Thank you in advance.
Regards.
That worked.
Thank you very much for your help.Forum: Fixing WordPress
In reply to: Delete all pages (thousands) except a few by their IDsThank you
Forum: Plugins
In reply to: [Simple Job Board] Templating is not working for meThank you for the reply, it works now.
I wonder why something essential like that is not mentioned in the documentation.Forum: Plugins
In reply to: [Simple Job Board] I want to make jobs my homepageHi @jerrykza, thank you for the reply.
Dashboard Settings > Readings > Your Homepage Display > there is no page called jobs over there.
any idea why, please?
jobs page seems custom, not like other pages, there is no edit page option for exampleForum: Plugins
In reply to: [Simple Job Board] I want to make jobs my homepageBut still i wonder, why can’t you set homepage in
jobboard => settings https://prnt.sc/100v0ze