Forum Replies Created

Viewing 15 replies - 46 through 60 (of 76 total)
  • Hello there,

    To achieve this, you’ll need to create a custom user profile field for selecting a category and then use that field to programmatically set the category of posts created by the user.

    You can use the user_contactmethods hook to add a custom field to the user profile. Here’s how you can do that:

    // Add custom user profile field
    function add_user_category_field($user) {
    $categories = get_categories();
    $selected_category = get_user_meta($user->ID, 'user_category', true);
    ?>
    <h3><?php _e("User Category", "blank"); ?></h3>

    <table class="form-table">
    <tr>
    <th><label for="user_category"><?php _e("Category"); ?></label></th>
    <td>
    <select name="user_category" id="user_category">
    <option value="">Select a category</option>
    <?php foreach ($categories as $category) : ?>
    <option value="<?php echo esc_attr($category->term_id); ?>" <?php selected($selected_category, $category->term_id); ?>>
    <?php echo esc_html($category->name); ?>
    </option>
    <?php endforeach; ?>
    </select>
    <br /><span class="description"><?php _e("Select a category for this user."); ?></span>
    </td>
    </tr>
    </table>
    <?php
    }
    add_action('show_user_profile', 'add_user_category_field');
    add_action('edit_user_profile', 'add_user_category_field');

    // Save the custom user profile field
    function save_user_category_field($user_id) {
    if (!current_user_can('edit_user', $user_id)) {
    return false;
    }
    update_user_meta($user_id, 'user_category', $_POST['user_category']);
    }
    add_action('personal_options_update', 'save_user_category_field');
    add_action('edit_user_profile_update', 'save_user_category_field');

    Next, you need to set the category of a post programmatically based on the user profile. You can use the save_post hook for this:

    function set_post_category_based_on_user($post_id) {
    // Check if it's a valid post and not an autosave
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
    return;
    }

    // Check if it's a post and not a revision
    if (get_post_type($post_id) != 'post') {
    return;
    }

    // Get the user ID of the author
    $author_id = get_post_field('post_author', $post_id);

    // Get the category assigned to the user
    $user_category = get_user_meta($author_id, 'user_category', true);

    if ($user_category) {
    // Set the post's category
    wp_set_post_categories($post_id, array($user_category));
    }
    }
    add_action('save_post', 'set_post_category_based_on_user');

    You will need to add this code to your theme functions.php file or via Code Snippet plugin. Give it a try but beware, adding code like this can cause a fatal error on your site if something is off, make sure you can undo the code change if things go south.

    Summary

    1. Add a custom field to the user profile to select a category from existing categories.
    2. Save the selected category when the user profile is updated.
    3. Automatically set the category of new posts based on the user’s selected category when the post is saved.

    This approach should provide a clean solution without relying on complex plugins.

    Kind Regards.

    Hello there,

    It seems that you are using Kadence theme, if that’s the case – please follow this tutorial on how to make the footer changes -> https://www.kadencewp.com/help-center/docs/kadence-theme/how-to-customize-the-kadence-footer

    Kind regards.

    Hello there,

    The 503 error usually means that server is overloaded, and the requests time-out because of that, if your site has cPanel on that A2 Hosting, can you check resource usage in cPanel? Also, check the traffic data, maybe bots are “hitting” your site and “eating” resources. Is your site hosted on a shared hosting environment?

    From the WordPress side you can use the https://www.ads-software.com/plugins/query-monitor plugin to see if there is something that creates long queries which are overloading the server.

    Check that and let’s see if there is more helpful information.

    Kind Regards.

    Hello there,

    Did you clear your browser cache, or did you try to see the site in the incognito window?

    Layout does not look broken on my end – https://ibb.co/mRG90Jp

    Kind Regards.

    Hi there,

    It seems that someone added inline CSS code to set thumbnails to 40% size -> https://prnt.sc/itrAyyQycMCvhttps://prnt.sc/cPfVteguWw2- – remove or adjust that code and thumbnails will be in full size.

    After you remove that code – you can set thumbnail size and use a plugin to regenerate thumbnail sizes, for example, this one -> https://www.ads-software.com/plugins/force-regenerate-thumbnails

    For padding I see that code is also added as inline CSS -> https://prnt.sc/j-dSSp-OTXG- – change the code at the place where you added this or if you can’t find it, you can use !important to override the CSS, for example:

    .entry-thumb img?{ padding-bottom: 20px !important;}

    But it’s better to sort that out at the inline CSS level, you should avoid using !important when it’s possible to avoid it.

    Kind Regards.

    Hi there,

    You can see the theme in the source code -> view-source:https://membersmarkproduct.com/ – it’s this theme -> https://generatepress.com

    You can’t grab the theme from their website, even if there is a way, it would be like stealing, but you have starter sites from Generate Press -> https://generatepress.com/site-library/ – if you buy that theme, you could install one of those starter sites, and adapt it with your site content.

    Kind Regards.

    Hello,

    Server side log should show what happens with cron job, why does it not execute, another idea that came up to my mind is – create a staging site, on another server (different IP address) and set up a cron job there, see will it work there?

    One more idea, but a complicated one – use Zappier to trigger a cron job:

    1. Using Webhooks by Zapier

    Zapier offers a “Webhooks by Zapier” app that you can use to send HTTP requests. You can use this to trigger a specific URL on your WordPress site that is designed to run a cron job. Steps:

    1. Create a Zap: Start by creating a new Zap in Zapier.
    2. Trigger: Set up the trigger event for your Zap (e.g., a specific time, a form submission, or any other trigger available on Zapier).
    3. Action – Webhooks by Zapier:
      • Choose “Webhooks by Zapier” as the action app.
      • Select “POST” or “GET” as the action event (GET is simpler for triggering URLs).
    4. Configure Webhook:
      • URL: Enter the URL of your WordPress endpoint that triggers the cron job.
      • Method: Choose GET or POST based on your setup.
      • If your endpoint requires authentication, you may need to include headers or other credentials.
    5. Test and Enable: Test the Zap to ensure it’s correctly triggering your WordPress cron job. Once it works, turn on your Zap.

    2. Creating a WordPress Endpoint for Cron Job

    To trigger a cron job in WordPress, you can create a custom endpoint in WordPress that runs your cron job code.Steps:

    1. Add a Custom Endpoint in WordPress:
      • You can add a custom REST API endpoint or a custom URL handler in WordPress. For example, you can add the following code to your functions.php or a custom plugin:
      add_action('rest_api_init', function () { register_rest_route('custom/v1', '/trigger-cron', array( 'methods' => 'GET', 'callback' => 'run_custom_cron_job', 'permission_callback' => '__return_true', // Adjust this for security )); }); function run_custom_cron_job() { // Your cron job logic here // Example: wp_schedule_event(time(), 'hourly', 'your_custom_cron_event'); return new WP_REST_Response('Cron job triggered', 200); }
    2. Point Zapier to Your Endpoint: Use the URL of the custom endpoint (e.g., https://yourwebsite.com/wp-json/custom/v1/trigger-cron) in your Zapier Webhook action.

    3. Security Considerations

    • Authentication: Protect your endpoint using API keys, basic authentication, or OAuth if sensitive operations are performed.
    • Permissions: Ensure that only authorized requests can trigger the cron job, either by checking for a secret key or using authentication headers.

    Summary

    While Zapier doesn’t directly trigger WordPress cron jobs, using Webhooks by Zapier allows you to create a custom setup to initiate your cron jobs remotely. This approach leverages WordPress REST API endpoints or other URL-based triggers to run the desired cron job.

    I suggested Zappier because on that way it’s like if you click to run a cron job manually – and if it works when you click to run it manually, it will work when triggered with Zapier.

    Kind regards.

    Hello,

    Strange, server side cron should work if everything else fails, can you re-check with WebToffee Support if you configured the cron job correctly? I see this on their site -> https://prnt.sc/DUdoZ22FisYU

    Kind Regards.

    Hello there,

    Strange, I see that you are using Elementor, did you try to reach out to their support for them to troubleshoot? I also see that you are using outdated Genesis theme (3.3.3?– 2020-08-10) – https://www.proteusind.com/wp-content/themes/genesis/style.css?ver=6.6.1 – I can’t say that your issue is related to the theme, maybe not – but you should have everything up-to-date, make a backup and try to update to the latest version – https://studiopress.github.io/genesis/changelog (3.5.0?– 2024-01-22).

    I hope you find this helpful, kind regards.

    Hello there,

    You can resolve this issue by adjusting the CSS, navigating to?Appearance → Customize → Additional CSS, and adding this code:

    #ast-scroll-top { font-size: inherit !important; }

    Before you do that, check if there is this code is already there -> https://prnt.sc/2Lo942fugv5k – and then just change “15rem” to “inherit”. Also, check if it’s maybe somewhere in the theme settings.

    Kind regards.

    Hello there,

    You need to revisit a way on which you built that slider, I see a lot of messy CSS, you did not account for bigger screens -> https://prnt.sc/6YVLOQdUTiDu – I can replicate the issue both on desktop, and mobile -> https://prnt.sc/-5foZqrJBebh – you should not lazy load LCP image, image from the banner should be excluded from lazy load, it should be preloaded in fact, find a settings in the ShortPixel plugin to exclude that image from lazy load, also check LiteSpeed plugin settings for images, maybe something there clashes with Shortpixel.

    Kind Regards.

    Hello there,

    Why do you use https://44.199.92.164.nip.io? Shouldn’t you replace IP address with a domain name? Step 5 of this tutorial -> https://docs.aws.amazon.com/en_us/lightsail/latest/userguide/amazon-lightsail-quick-start-guide-wordpress-multisite.html

    Then you should follow one of these two tutorials -> https://docs.aws.amazon.com/en_us/lightsail/latest/userguide/amazon-lightsail-add-blogs-as-domains-to-your-wordpress-multisite.html or https://docs.aws.amazon.com/en_us/lightsail/latest/userguide/amazon-lightsail-add-blogs-as-subdomains-to-your-wordpress-multisite.html

    If you read that documentation, you can see that you can enter any name without dots, and add a site and then you can edit it right afterwards, to whatever you need.

    I hope you find this helpful, kind regards.

    Hello there,

    Did you test and see if other cron jobs are running automatically? To determine if it’s an issue for all cron jobs, not just to the one specific cron job which you are mentioning? Check wp-config.php to see if there is maybe a directive that disables cron jobs functionality.

    Is there anything interesting in the Cron Manager plugin debug logs?

    If you can’t resolve this from the WP end, you could set up a cron job on the hosting end, which could be an alternative solution.

    Kind regards.

    Hello there,

    From some reason I can’t see the domain name in question, judging by your description of the issue, can you check if you forced all URLs to use HTTPS?

    Also, check if you use some security plugins like Wordfence or similar?

    It is also possible that something on your hosting end is blocking the requests and then you end up with 429 error. If you excluded plugins/themes as possible cause for the issue – then it’s the hosting end that you need to look at, do you have access to hosting logs?

    I hope you find this reply helpful, kind regards.

    Forum: Everything else WordPress
    In reply to: Post help

    Hello,

    There are more ways you can achieve this:

    1. You can add custom CSS to Go to Appearance → Customize – Custom/Additional CSS section, this code -> div.taxonomy-category.wp-block-post-terms {display: none;}
    2. Use a function to hide uncategorized category, by adding it to your theme’s functions.php file ->
    function remove_uncategorized_category() {
    $categories = get_categories( array( 'exclude' => array( 1 ) ) ); // Replace 1 with the ID of your uncategorized category
    wp_set_object_terms( get_option( 'page_on_front' ), array_values( wp_list_pluck( $categories, 'term_id' ) ), 'category' );
    }
    add_action( 'init', 'remove_uncategorized_category' );

    3. Or just add a new category name and assign it to your post, then the post will show some other name instead of uncategorized.

    I hope you find this helpful, kind regards.

Viewing 15 replies - 46 through 60 (of 76 total)