Questions tagged [php]

For questions about the server-side programming language that the WordPress core, plugins and themes are written in. Questions about using PHP outside a WordPress context are off-topic but might be asked on Stack Overflow.

Filter by
Sorted by
Tagged with
0 votes
3 answers
40 views

Help with AJAX request

I am creating an events plugin with a commenting section for each event. I am able to save each comment, but the problem I'm having now is that I am taken to admin-ajax.php which is blank. When the ...
Darth Mikey D's user avatar
0 votes
1 answer
13 views

Compare user meta values before update them

I have this pseudo code I'm writing to compare the user meta values. I have some user meta that will hold a null value until the user update his account, before the values are updated I need to check ...
ICTDEV's user avatar
  • 113
0 votes
0 answers
21 views

404 error on page reload

I have created a WordPress based web app that will rely on template pages that will host some vue.js different front-end apps. I've added this code to the theme functions file to rewrite all the ...
ICTDEV's user avatar
  • 113
0 votes
1 answer
19 views

Execute scheduled cron with ajax call to wp-cron.php

According to this question where my doubt on how to schedule an email sending each 24 hours, I've modified my plugin code to use a custom action hook and the wp_schedule_single_event() to achive the ...
ICTDEV's user avatar
  • 113
0 votes
0 answers
11 views

Scrape Meta data from another platform and put in wordpress site

I've recently built a site in wordpress and the original site was using Travelize CMS as backend. But in the original site there were meta data in all the pages which aren't currently available in the ...
buzz's user avatar
  • 101
0 votes
1 answer
132 views

PHP Warning: Attempt to read property "id" on null

I'm receiving a php warning in the error when I run the below script in the footer.php file. The code works but is there is a way to write it better? <?php global $product; $mpn = ...
Ricardo Parsons's user avatar
0 votes
0 answers
22 views

How to pull through page title depending on which radio button is selected on the specific page?

I'm pretty new to Wordpress, ACF and PHP. I am currently working on a project, the website has 11 different sports centres all with different sport/activities, on each centre they will have a sidebar ...
jonnyplat's user avatar
0 votes
0 answers
7 views

comments meta box not showing in my plugin post type

I´m still pretty new to coding, I might not understand lingo very well, but let me explain the best I can. here is an image of what I want. this is the comic easel plugin. I have comments checked in ...
Lunarian3's user avatar
0 votes
1 answer
13 views

Deleting all CPT related to user deleting

i have some Custom post type with "user-id" metakey how can i delete all row in table on deleting user request? the user is not author of post, he have only metakey (user_id) stored inside ...
Fabio's user avatar
  • 1
1 vote
0 answers
32 views

WordPress PHP Redirect - which hook to use?

I have site where users sign up to a subscription. When the subscription has ended (I can query that using PHP), I want the user to be redirected to the "subscription-ended" page. My current ...
roland's user avatar
  • 21
0 votes
2 answers
71 views

wp_mail - send emails after 24 hours from users registration

I have writed a lugin that will send emails after the user completed a custom registration form. I need to send emails after 24 hours from registration, is this possible by using the wp mail function? ...
ICTDEV's user avatar
  • 113
0 votes
1 answer
16 views

Update shortcode values using ajax call

I'm having a problem with a calendar, I've made a shortcode which returns events links in a grid that shows the current month view. I set $month_index in order to navigate through months (default is 0 ...
Enrico's user avatar
  • 11
0 votes
1 answer
54 views

Display two previous posts on single.php

At the bottom of single.php, I want to display "card" links to the next and previous posts in chronological order. This is pretty easy thanks to get_next_post() and get_previous_post, no ...
doofusb0y's user avatar
0 votes
0 answers
8 views

Woocommerce Payment Method Change

How do I go about setting all orders that are on-hold to have a Payment method of cod? Any tips on what hooks I can use would greatly be appreciated! Thanks Edit: I have written this code but the ...
Nathan Wilson's user avatar
0 votes
1 answer
17 views

Adding Author Filter to CPTs

I'm trying to add an author filter to the WP Admin pages for the CPTs 'booking' and 'ticket' The code below works when using only one post type, but adding || and the second cpt stops it. I've tried ...
Blakar1988's user avatar
0 votes
1 answer
162 views

Manipulating the allowed inner blocks of a core-gutenberg-block?

I had special requirements for a Button-Block for the Gutenberg-Editor, so I built a custom block "myproject/button". Now I try to use the core/buttons block with this new button block, but ...
FbnKlmn's user avatar
  • 13
0 votes
0 answers
18 views

Two different URLs, One site

How can I have the same WordPress site run on two different URLs? For example, www.brand1.com and www.brand2.com. They have the SAME content, just some different graphics or ads (which could be ...
Owen's user avatar
  • 101
0 votes
0 answers
7 views

How to add usermeta for existing users when user profile is updated

I need to add an usermeta field for users when they decide to modify some account informations on a custom form. At the moment I'm calling the wp_update_user() but since I want that the modifications ...
ICTDEV's user avatar
  • 113
0 votes
0 answers
23 views

How can I display formatted content using the_content filter?

I am using the_content filter to append comment summaries to posts on a blog page. That part of my code works. I am having a problem with the display of pages where they are not formatted and ...
bigmoxy's user avatar
0 votes
0 answers
19 views

Woocommerce - how can i add items to cart using onclick - multiple items at once with custom prices

I am actually creating an order form (sort of). Based on the items a customer selects, logic needs to be applied to calculate the custom price per item. Custom price is now stored in hidden input ...
Robert's user avatar
  • 1
0 votes
2 answers
32 views

Too few arguments - wp_login action

I'm looking for a way to avid that some custom users roles are able to see wp-admin dashboard. I've found this topic and in my plugin class I've tried to use the two action suggested, but I will get ...
ICTDEV's user avatar
  • 113
0 votes
1 answer
23 views

wp_head filter not executed inside custom class

I have this code in a simple plugin that is supposed to make wordpress unbranded: <?php /* * Class to remove wp-* branding from WordPress * @package users-manager.php */ class WpUnbrand { ...
ICTDEV's user avatar
  • 113
0 votes
0 answers
19 views

redirect logged users to custom front-end insetad of wp-admin

I have this three functions in my custom plugin. I have created a custom front-end and I'm using an SSO plugin that will get the registered data from usermeta table to pass them to magento if an user ...
ICTDEV's user avatar
  • 113
0 votes
0 answers
18 views

$wpdb->insert writes a record twice for some reason, when my custom developed plugin calls my class function once

My custom code in my custom (class-based) plugin for some reason, writes the same record twice, when as you can see it's called once. This double write also happens even when I do the same type of ...
Mario's user avatar
  • 1
0 votes
1 answer
27 views

wp_logout action hook is not firing

Why the user meta value is not being changed after logout using the following code: function update_login_status_on_logout() { $user_id = get_current_user_id(); if ($user_id) { ...
rock's user avatar
  • 1
0 votes
1 answer
17 views

Pagination with WP_query giving same items in each page

I have around 250+ blog posts and currently in my custom theme I've implemented the functionality of showing the blogs with pagination option. But in all pages it is showing the same posts. <?php $...
buzz's user avatar
  • 101
0 votes
0 answers
27 views

How to add a shortcode for an image in the following function

This is a function by Tobias Keller for PRG Pattern Link Masking where title shortcode is link text. How то add image shortcode alternatively instead text ? $use_prg = new prg_pattern(); class ...
arteaster's user avatar
0 votes
0 answers
13 views

How to retake a webcam image through phone camera

am creating a form where guests take a picture through their phone camera before submitting the form. So the webcam works well on desktop/computer but on mobile devices I notice when the Retake ...
Titus's user avatar
  • 1
0 votes
0 answers
20 views

register_rest_route, Compare purchase codes and send a response

I have a question, I would be grateful if someone could help me I am working on WordPress plugins, I have 2 files, the first file is Verification which is for users and the second file is the ...
pooyan golkar's user avatar
0 votes
0 answers
31 views

Phone number custom field and woocommerce updating issue noticed

I use Wordpress user frontend plugin to allow guests to post their woocommerce product on my website but I have observed some issues. Firstly, I added a phone number field in the form, then also added ...
Titus's user avatar
  • 1
0 votes
0 answers
22 views

(plesk)After adding 1000 youtube url to my 1000 different wordpress article, my all websites doesnt show yt url as embed

i added 1000 article with 1000 youtube url, i directly pasted youtube url, but after that, including that site, my all sites on my dedicated hosting doesnt show the youtube embed after i paste direct ...
teamzane's user avatar
0 votes
1 answer
38 views

How to capture number input from wordpress form into acf field in woocommerce

WUFP Phone fieldI am trying to capture the phone number of guests that submit a form on my woocommerce website using the advancedwoocommerce custom field for phone no custom field plugin. I noticed ...
Titus's user avatar
  • 1
0 votes
0 answers
18 views

Replace attribute terms with wp_update_term (woocommerce)

On the edit.php?post_type=product&page=product_attributes page I want to replace (when I import a product via my importer plugin) the term name of the Terms attribute with a new name. For example:...
Linux's user avatar
  • 1
0 votes
0 answers
26 views

How to add icon to WooCommerce add to cart button

in woocommerce, I want to add an icon from the iconify library to the add to cart button of my site I made some attempts, but I did not get the desired result. I used WooCommerce hooks, but this icon ...
MahmoodZamaniNemati's user avatar
0 votes
0 answers
17 views

How do I see logs of critical errors of specific pages without enabling public debug for everyone?

I have a site that works well in production, say with N pages currenly being used by users. I am doing some PHP scripting in one specific page and I want to debug some data. Usually in projects not ...
Xavi Montero's user avatar
0 votes
0 answers
25 views

How to fetch WordPress Gallery Images to a Custom Post Type?

I am using the WordPress Email Contact Form plugin to create a custom contact form. I want to be able to fetch images from the WordPress gallery and display them in the contact form. I have tried ...
Muhammad Usman Qureshi's user avatar
1 vote
1 answer
48 views

How prevent STDOUT of Plugin_Upgrader->upgrade(...)?

🖥️ Code function my_custom_endpoint(WP_REST_Request $request) { $plugin_file = $request->get_param("plugin_file"); if(!class_exists('Plugin_Upgrader')) { require_once ABSPATH ....
Adrien Villalonga's user avatar
0 votes
1 answer
168 views

WP_Error Object in wp_remote_post & wp_remote_get

I am using localhost and working on a wordpress plugin, I try to get and post data with wp_remote_get and wp_remote_post,i installed lmfwc and i create a rest-api-key, as you can see i used consumer ...
pooyan golkar's user avatar
0 votes
0 answers
39 views

Execute a PHP Function when a Block is used and access it's attributes

I've just build my first block using the @wordpress/create-block package. Everything is working as expected however I need to access the attributes on save and place a script containing a JSON schema ...
Walrus's user avatar
  • 131
0 votes
2 answers
46 views

Import Wordpress header / footer into an external page(s)

I have an external forum application, which has an option to include a header and footer as HTML. In theory I could use HTML to create the header, but this would be very hard to keep up to date, even ...
Ian's user avatar
  • 1
0 votes
1 answer
30 views

add_action() not working for admin

Making my own custom plugin and using add_action several times without a problem with one exception. Currently function below are located in functions.php in the appropriate themes folder. function ...
PerK's user avatar
  • 28
-1 votes
1 answer
22 views

Custom rest fields not loaded in rest api cpt response

I have a custom endpoint that will be used from my vue app to load custom post type I've registered using a custom plugin. I need to add some custom fields to the response when the posts are loaded ...
ICTDEV's user avatar
  • 113
0 votes
0 answers
24 views

Jetpack update causes Wordpress to report PHP Fatal error - relevance unclear

Upon updating the Jetpack by WordPress.com plugin from v7.7 to v12.5, WordPress v6.3.1 reports the following: PHP Fatal error: Uncaught Error: Class 'Automattic\Jetpack\Roles' not found in /www/wp-...
HeymJ's user avatar
  • 1
0 votes
0 answers
20 views

Add 2 links in between the navigation using the Breadcrumb Navxt plugin hook

I am using the Breadcrumb NavXT Plugin. I have 2 links at a page, and want to add 2 more links in between on that specific page. I used the below hook, but did not get the result. add_filter('...
Rizeen's user avatar
  • 101
0 votes
1 answer
25 views

how to test for options(fields) in settings API?

I've created an options page in wordpress with this code: <?php add_action( 'admin_menu', 'rtwhc_add_admin_menu' ); add_action( 'admin_init', 'rtwhc_settings_init' ); function rtwhc_add_admin_menu(...
rudtek's user avatar
  • 5,979
0 votes
0 answers
12 views

change the blog in the url if you go from a specific page wordpress

I have a products page on my site, and the products themselves are actually posts. And also, I have a blog with posts. When I am on the products page, I have a link like: site.com/products And go to ...
s.kuznetsov's user avatar
0 votes
1 answer
26 views

Remove custom menu pages for admin users

I've added some custom menù pages to my WordPress dashboard using the add_menu_page() function. I need to remove these pages for super admin roles, but the remove_menu_page() seems not working. This ...
ICTDEV's user avatar
  • 113
0 votes
0 answers
19 views

Custom uploader - Upload files and save link into database

I'm working on a file manager plugin. I need to store the saved files in custom folders and save the link into database to be able to get all the files and folders structure inside my vue front-end. ...
ICTDEV's user avatar
  • 113
0 votes
0 answers
14 views

Can external API content be added to Rest API in Wordpress

Is it possible to fetch data from an external API, and put them inside of Wordpress REST API? For example, schema would look like this $api = 'https://valorant-api.com/v1/agents'; $json_data = ...
Jovan Jovanovic's user avatar
0 votes
0 answers
25 views

Sort Woocommerce Products with Numbered Titles Numerically

I have a woocommerce shop with many products all of which have numbered titles from 1-3000 and the problem is, the alphabetical sorting is leaving me with an order like this: 1, 10, 11, 12, 100 and so ...
Hangman's user avatar