Category: wordpress

  • Fix 404 error on nginx

    Fix 404 error on nginx

    Sometimes you get unexpected 404 error from Nginx server. And I am going to tell you how I fixed the issue.

    You can fix that easily by the following steps:

    Step 1 (Debugging):

    You first need to find out the reason. For that, you can the first login to your server via ssh and check the error log for Nginx server.

    Open the following file: /var/log/nginx/error.log and check the latest errors.

    In my case I was having the following error:

    2020/02/28 08:19:02 [error] 17627#17627: *14299 upstream sent too big header while reading response header from upstream, client: 172.31.4.43, server: yoursite.com, request: "GET /wp-login.php?action=switch_to_user&user_id=2928&nr=1&_wpnonce=9085bda773&redirect_to=https%3A%2F%yoursite.co%2Fmembers%2Fdesigner-buddyboss%2F HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.1-fpm.sock:", host: "yoursite.co", referrer: "https://yoursite.co/members/designer-buddyboss/"

    Step 2 (Solution):

    After exploring on google I found this solution which worked for me. We need to add the following lines into the Nginx config file:

    client_max_body_size 128m;
    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;

    Now the following file could be responsible for your site:

    Check if this file available /etc/nginx/sites-enabled/your_site.conf ( This was the responsible file in my case )

    OR

    /etc/nginx/sites-available/your_site.conf

    OR

    /etc/nginx/sites-available/nginx.conf

    Open one of the files.

    Step 3 (Apply Solution):

    Now add those 3 lines into the config file like this

    After adding this restart Nginx server by the following command:

    sudo service nginx restart

    That’s it!!!!

  • BuddyPress Re-post Activity WordPress Plugin

    BuddyPress Re-post Activity WordPress Plugin

    Sometimes you like someone’s post in activity thread and you want to re-post that activity publically or on your group.

    So now you can re-post an activity from BuddyPress activity page with the help of this plugin.

    What this plugin does? It will provide a button for reposting activity. We can also enable/disable this functionality from backend.

    Screenshots

    1. Re-post any activity by clicking on the “Re-Post” button.

    2. Select where to re-post.

    3. Enable/Disable re-post functionality.

     

    https://www.youtube.com/watch?v=vBAb2s422LY

    WP Plugin URL:  https://wordpress.org/plugins/bp-repost-activity/

    GitHub URL: https://github.com/BhargavBhandari90/bp-repost-activity

  • User avatar in BuddyPress notification loop

    User avatar in BuddyPress notification loop

    BuddyPress by default doesn’t show user avatar in the notifications. But you can do that by simply adding couple of lines in notification loop.

    BuddyPress stores the other user id as secondary id.

    Here is the code to be used in notification loop.

    echo bp_activity_avatar(
        array( 'user_id' => bp_get_the_notification_secondary_item_id() )
    );
    

    That’s it…

  • Delete orphan data from post meta in WordPress

    What is orphan data?

    Sometimes there are entries in postmeta table for those ids which is not exist in main post tables during testing new functionality or developing any plugins.

     

    Why you should remove orphan data?

    It’s not necessary if you have limited data. But if you have a huge data in your database, then you will need to remove those unnecessary data.

     

    Use below code snippet for removing orphan data from postmeta table: TAKE A BACKUP BEFORE RUNNING THE SCRIPT.

    DELETE pm FROM wp_postmeta pm
    LEFT JOIN wp_posts wp ON wp.ID = pm.post_id
    WHERE wp.ID IS NULL

     

     

     

  • BuddyPress Profile Field Duplicator WordPress Plugin

    BuddyPress Profile Field Duplicator WordPress Plugin

    Sometimes people needs to add the same profile field many times. Specially when it comes to add muti-select, radio, checkbox etc., then it will be time consuming and might be irritating.

    So now you don’t need to add the same field again and again. It’s just a matter of one click now.

    See the screenshot below

    You can get this simple plugin from here.