Need Help in WordPress form live documentation [closed]

I am currently working on a WordPress website for a client, and I’ve encountered a challenge in implementing a live documentation preview feature in a form, similar to what is demonstrated on the following webpage: https://validgrad.com/transcript-maker/.

The client’s requirement is to create a university degree application form where users can see a real-time documentation preview based on their selections in the form.

After some research, I found that the implementation involves a combination of a form plugin and custom JavaScript to dynamically update the documentation sections based on user input. However, due to my limited expertise in this area, I am seeking your assistance to successfully implement this feature.

The primary functionalities required are as follows:

Dynamic Form Fields: The form should include various fields related to personal information, academic history, and other relevant details.
Conditional Logic: Utilize conditional logic within the form plugin to show or hide sections based on user input (e.g., degree type, program choice).
Live Documentation Preview: Implement custom JavaScript to dynamically update the content of documentation sections based on user selections without refreshing the page.
I have already considered using popular form plugins like Gravity Forms, WPForms, or Formidable Forms, but I am open to your suggestions based on your expertise.

If you are available to assist with this project or if you can recommend a specific approach or plugin, I would greatly appreciate your guidance. Additionally, if you could provide an estimate of the time and effort required for this task, it would be immensely helpful.

Thank you in advance for considering this request. I am eager to collaborate with you on this project and ensure its successful completion.

auto generate number is not working at the start of new year

I am trying to generate my bill no in following sequence in php
L5- 0124-0001 (where L5 is company name, 01 representing month and 24 representing year, where as last four digit is for serial number) , I was using this code since October 2023, everything was working fine until end of year 2023, but as today year 2024 start, its stop working, (company name is correctly display, year month as well but last four digit are not incremented when new bill need to be generated. it remain 0001 for all the bills, where as it should L5-0124-0002 and so on …….. below is the code

$CI = "L5"; //Example only
$CIcnt = strlen($CI);
$offset = $CIcnt + 6;

// Get the current month and year as two-digit strings 
$month = date("m"); // e.g. 09 
$year = date("y"); // e.g. 23  

// Get the last bill number from the database 
$query = "SELECT patientno FROM iap2 ORDER BY patientno DESC LIMIT 1"; 
$result = mysqli_query($con,$query); 
// Use mysqli_fetch_assoc() to get an associative array of the fetched row 
$row = mysqli_fetch_assoc($result); 
// Use $row[‘patientno’] to get the last bill number 
$lastid = $row['patientno'];     

// Check if the last bill number is empty or has a different month or year
if(empty($lastid) || (substr($lastid, $CIcnt + 1, 2) != $month) || (substr($lastid, $CIcnt + 3, 2) != $year)) { 
    // Start a new sequence with 0001 
    $number = "$CI-$month$year-0001"; 
} else { 
    // Increment the last four digits by one 
    $idd = substr($lastid, $offset); // e.g. 0001 
    
    $id = str_pad($idd + 1, 4, 0, STR_PAD_LEFT); // e.g. 0002 
    $number = "$CI-$month$year-$id"; 
} 

Fillter array by key

I have a simple question, I did it in javascript, but in php everything is different:
In my request when I did dd($request->all()) it returned an array like this

$request = [
  'question_ru' => 'question ru',
  'asnwer_ru' => 'answer ru',
  'question_uz' => 'question uz',
  'asnwer_uz' => 'answer uz',
  'question_en' => 'question en',
  'asnwer_en' => 'answer en',
];

Now my problem is, I need to write a function which gets two argument: 1) a request, 2) a key and returns an array like this

function filter_array_by_key($array, $key) {}

function filter_array_by_key($request, 'title') =>

$result = [
  'title' => [
    'ru' => 'question ru',
    'uz' => 'question uz',
    'en' => 'question en',
  ],
];

‘JS VERSION’

export function filterFormDataByKey(object: Object, key: string) {
  let startNumber = key.length + 1
  const data = lodash.entries(object)

  let filteredObject = {}

  data.forEach((arr) => {
    if (arr[0].startsWith(key)) {
      let innerObj = { [arr[0].slice(startNumber)]: arr[1] }

      Object.assign(filteredObject, innerObj)
    }
  })

  return filteredObject
}

and it worked well!

How to Ensure All Language Files Are Updated with New Keys in Laravel?

I am working on a Laravel project with multiple language support and I’ve recently added a new key-value pair to my en/messages.php file:

'back' => 'Back'

I have multiple language files for different locales, such as vi, fr, id, etc., and I need to make sure that this new key is added to all of them with the appropriate translations.

Considering the large number of language files, it’s quite challenging to manually check each file to confirm if the translation has been added. Is there an automated way or a tool within Laravel that can help me verify that all language files have been updated accordingly?

I’m looking for a solution that would either:

Alert me if a key is missing in any language file.
Provide a report of missing translations across all language files.
Any suggestions or best practices on how to manage this efficiently would be greatly appreciated!

Thanks!

Unsed variables not showing for php

The default PHP setup in VSCode doesn’t show warnings for unused variables. Despite installing extensions, the issue persists. Seeking help to configure VSCode for PHP warnings on unused variables.

Installed some extensions that I thought would help but they didn’t

livewire 3 how to store foreach value using form

hello I’m new for livewire 3 I have table inside form, data table having radio button for yes or no
after selecting yes or no I’m going to submit that form that time I want to store fetch detail like id and name along this. now I’m any getting radio button value, me to solve

form page
enter image description here
my code form

<div class="modal-body">
    <form wire:submit.prevent="Save" autocomplete="off">
      <div class="card card-bordered card-preview table-responsive ">
        <div class="card-inner "> 
          <table class="datatable  table   ">
            <thead>
              <tr>
                <th style=" border: 1px solid black; text-align: center;">SL</th>
                <th style=" border: 1px solid black; text-align: center;">ID No</th> 
                <th style=" border: 1px solid black; text-align: center;">NAME</th>
                <th style=" border: 1px solid black; text-align: center;">YES</th>
                <th style=" border: 1px solid black; text-align: center;">NO</th>
              </tr>
            </thead>
            <tbody> 
 @foreach ($UserDetail as $key=>$UserDetails) 
 @php $ID = 0+$key @endphp
<td style=" border: 1px solid black; text-align: center;">
                {{ $key + 1  }}
              </td> 
              <td style=" border: 1px solid black; text-align: center;">
                {{ $UserDetails->id }}
              </td>
              <td style=" border: 1px solid black; text-align: center;">
                {{ $UserDetails->name }}
              </td>
              <td style=" border: 1px solid black; text-align: center;">
                <div class="custom-control custom-control-md custom-radio ">
                  <input type="radio" wire:model="TableInput.{{$ID}}.data" class="custom-control-input" name="TableInputs[{{$ID}}]" id="sv2-preference-fedev{{$ID}}" value="YES" required>
                  <label class="custom-control-label" for="sv2-preference-fedev{{$ID}}"></label>
                </div>
              </td>
              <td style=" border: 1px solid black; text-align: center;">
                <div style="text-align: center;" class="custom-control custom-control-md custom radio"><input type="radio" wire:model="TableInput.{{$ID}}.data" class="custom-control-input" name="TableInputs[{{$ID}}]" id="sv2-preference-uxdis{{$ID}}" value="NO" required>
                  <label class="custom-control-label" for="sv2-preference-uxdis{{$ID}}"></label>
                </div>
              </td> 
              </tr> 
      @endforeach 
            </tbody>
          </table>
        </div>
      </div>
      <br>
      <div  >
        <button type="submit" class="btn btn-md btn-primary">SAVE  </button>
      </div>
    </form>
  </div>

Controller
class StudentAttendance extends Component
{

public $name; 
public $id;  
public $TableInput = [];


public function mount()
{
  $this->User       = User::all();   
}

public function Save() 
{   
    $bel = Data::create([ 
         
        'Id'                     => $value['Id'],
        'name'                   => $value['name'],
        'data'                   => $value['data'],
    ]);
} 
} 

}

Eloquent: How to get a result based on ranges

I have a laravel project and in this project there is a table like this:

enter image description here

I need to run a query and return a result where the $circulation variable is in range of the column range_from and range_to.

So I tried this:

$tariff = StoreCategoryTariff::where('option_value', $side)
      ->whereBetween('range_from', [$circulation, 'range_to'])
      ->orWhereBetween('range_to', [$circulation, 'range_from'])
      ->first()->price;

But this is wrong..

I also tried this one:

$tariff = StoreCategoryTariff::where('option_value', $side)
      ->where('range_from', '>=', $circulation)
      ->where('range_from', '<=', $circulation)
      ->first()->price;

But didn’t get the result. So how to properly check for the result where circulation is in range ?

Correct way to stop a function working on a certain page

I am trying to stop this currency switcher showing on a certain page on my wordpress site. I’ve checked this is definitely the correct page ID but the function is still showing the currency switcher on this page. Any help would be appreciated

<?php 
    if ( function_exists( 'wc_get_currency_switcher_markup' )  && !is_page(7283)); {
        $instance = [
            'symbol' => true,
            'flag'   => true,
        ];
        $args = [];
        echo wc_get_currency_switcher_markup( $instance, $args );

    }
?>

Inspect Element showing the page id I am trying to prevent showing the switcher on

I have tried the above code and was expecting the currency switcher to not show on this page.

PHP Curl accessing file always show 403 error

I am trying to access a JSON file through Curl but it always shows a 403 forbidden error.

I am using Cloudflare on my site.

Here is the code, only else block is running.

I can access this JSON through browser and FTP there is no error but through Curl and wget it shows 403.

$url = "https://example.com/pub/media/sample.json";
            
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);

curl_setopt($ch, CURLOPT_USERAGENT, 'User-Agent: curl/7.39.0');

$result = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

curl_close($ch);

if ($code == 200) {
    $status = true;
} else {
    $status = false;
}
curl_close($ch);
        
if ($status){
    $response = $this->resultFactory
        ->create(MagentoFrameworkControllerResultFactory::TYPE_JSON)
        ->setData([
            'status' => "sucess", 'response' => 'sucess']);
    return $response;
}
else{
    $response = $this->resultFactory
        ->create(MagentoFrameworkControllerResultFactory::TYPE_JSON)
        ->setData([
            'status' => "fail", 'response' => $code.' My File Error '. $url]);
    return $response;
}

PHP random string with random spaces

I found this code to generate a random string with random spaces, but I can’t understand how it works. I’m mainly interested in the if statement “if($sp–)”, what does it mean?

<?php
$chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$len = strlen($chars)-1;
$space = rand(1, 5);

for ($x = 0; $x <= 10; $x++) {
if($space--) {
   $pos = rand(0, $len);

  echo substr($chars, $pos, 1);
  
} else {
  
  echo ' ';
  $sp = rand(1, 5);

}

}

Trouble Sending Emails with PHP Using PHPMailer: Getting ‘Cannot Send Mail’ Error

I’m encountering an issue while trying to send emails using PHP’s PHPMailer library. I’m getting an error that says ‘Cannot Send Mail.’ and I’ve tried different ways to send mail even I got helped from ChatGpt but I could not. I’ve followed the documentation and my code looks like this:

<form action="mail.php" method="post">
    <input type="text" name="name">
    <input type="email" name="email" id="">
    <input type="submit" value="submit">
</form>

<?php
use PHPMailerPHPMailerPHPMailer;
use PHPMailerPHPMailerException;

require __DIR__ . '/PHPMailer-master/PHPMailer.php';
require __DIR__ . '/PHPMailer-master/Exception.php';
require __DIR__ . '/PHPMailer-master/SMTP.php';

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $name = $_POST['name'];
    $email = $_POST['email'];

    $mail = new PHPMailer(true);

    try {
        // SMTP configuration
        $mail->isSMTP();
        $mail->Host = 'smtp.gmail.com';
        $mail->SMTPAuth = true;
        $mail->Username = '[email protected]';
        $mail->Password = 'mypassword'; // Replace with your Gmail password
        $mail->SMTPSecure = 'tls';
        $mail->Port = 587;

        // Sender and recipient details
        $mail->setFrom('[email protected]', 'Ahmed Maajid');
        $mail->addAddress('[email protected]'); // Set your Gmail address as both sender and recipient

        // Email content
        $mail->isHTML(false);
        $mail->Subject = 'New submission from your website';
        $mail->Body = 'Name: ' . $name . "nn" . 'Email: ' . $email;

        $mail->send();
        echo 'Email sent successfully!';
    } catch (Exception $e) {
        echo 'Oops! There was a problem: ' . $mail->ErrorInfo;
    }
}
?>

Online streaming of video on the site live and non-downloadable

I have an online training site made with Laravel.
I want the training videos to be non-downloadable.
The user cannot download them.
Play online only.
The video link is encrypted and cannot be recognized.
The videos are uploaded on my own host.
What can I do?
Please let me know if there is a ready code.

Online streaming of video on the site live and non-downloadable

Stackposts ffmpeg error (Instagram videos)

I am trying to post Instagram Reels via Stackposts (Ubuntu/nginx) but I am facing this error message:

For sharing videos on Instagram, you have to install the FFmpeg library on your server and configure executables path.

error message

I have ffmpeg installed but it still won’t work:

ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil      56. 70.100 / 56. 70.100
libavcodec     58.134.100 / 58.134.100
libavformat    58. 76.100 / 58. 76.100
libavdevice    58. 13.100 / 58. 13.100
libavfilter     7.110.100 /  7.110.100
libswscale      5.  9.100 /  5.  9.100
libswresample   3.  9.100 /  3.  9.100
libpostproc    55.  9.100 / 55.  9.100

Does anyone have an idea on how to fix this?

I have tried to modify the file permissions of the library located in /bin/ffmpeg for the nginx user (www) and I have tried to move the binary to the location of the Stackposts installation.

TextLocal SMS Gateway API using PHP without rawurlencode

I am sending SMS using TextLocal.in API but this is how it looks because of line breaks in my SMS template.

It looks like this.

enter image description here

Please take a look at the contents of the $message variable. If I even mistakenly remove the line break then the SMS is not sent and response returns as “Invalid Template”. Not only that, it even “looks bad” in the code placing the text this way and whenever I see it I feel a sudden urge to change it. Therefore, to ensure that things are intact forever and minimize the chances of errors, I would like to change it to this Hi, welcome. Your Login OTP is '.$code.'<br><br> Please use this OTP to login to your account and connect with people and access ebooks.<br><br> Shubham Jha. However, it doesn’t work. Only the former works and SMS is successfully sent. How can I change it ?