Complicate question -> update fields ACF post object query with CPT accessible only for the user

Hope you are ready to start working on one hard problem of field objects update

Here is my problem

CPT_A has an ACF field that returns either 0 or 1
CPT_B has a post object value to select any of the CPT_A

CPT_C has a repeater field and one of the subfield is a post object field to select one of the CPT_B

The problem is :
I’d like to be able for the CPT_C to be able to select CPT_B only if ACF value from CPT_A is true.

I believe I would need to use the ACF function as follow

add_filter( 'acf/fields/post_object/query?name=contact_module_credential', 'my_acf_fields_post_object_query', 10, 3 );
function my_acf_fields_post_object_query( $args, $field, $post_id ) {

    $contactmodules_id = array();
    $argsm         = array(
        'post_type'  => 'modules',
        'meta_key'   => 'contact_or_keywords',
        'meta_value' => "contact",
    );

    /* Using WP_Query */
    $my_query = new WP_Query( $argsm );
    if ( $my_query->have_posts() ) :
        while ( $my_query->have_posts() ) : $my_query->the_post();
            array_push( $contactmodules_id, get_the_ID() );

        endwhile;
    endif;

    wp_reset_postdata(); /* Reset post data to original query */

    $args('meta_query') = array(
        array(
            'key'     => 'contact_module_credential',
            'value'   =>  $contactmodules_id,
            'compare' => 'IN'
        )
    );

    return $args;
}


any idea ?

javascript – POST request ERROR: ‘Access denied: Invalid token, wrong code’

I am trying to make a POST request using NODE but is throwing error. Here what I am trying to do is to generate TOTP with Headers and SHA512 hashed Token in NODE. In the header, we have to pass my private GITHUB GIST URL and my EMAIL_ID, that’s why I couldn’t share it here. Can you plz help! Here is my node code:

const axios = require('axios');
const base64 = require('base-64');
const utf8 = require('utf8');

const { totp } = require('otplib');


const reqJSON = 
{
    github_url: GITHUB_URL,
    contact_email: MY_EMAIL
}
const stringData = JSON.stringify(reqJSON);

const URL = 'https://api.challenge.hennge.com/challenges/003';
const sharedSecret = reqJSON.contact_email + "HENNGECHALLENGE003";

totp.options = { digits: 10, algorithm: "sha512",  epoch: 0 }

const myTotp = totp.generate(sharedSecret);
const isValid = totp.check(myTotp, sharedSecret);

console.log("Token Info:", {myTotp, isValid});

const authStringUTF = reqJSON.contact_email + ":" + myTotp;
const bytes = utf8.encode(authStringUTF);
const encoded = base64.encode(bytes);
const createReq = async () =>
{

    try 
    {

        // set the headers
        const config = {
            headers: {
                'Content-Type': 'application/json',
                "Authorization": "Basic " + encoded
            }
        };

        console.log("Making req", {URL, reqJSON, config});

        const res = await axios.post(URL, stringData, config);
        console.log(res.data);
    }
    catch (err)
    {
        console.error(err.response.data);
    }
};
createReq();

Basically, what I have to do is to submit my code which is in my private gist github profile. But when I run node myfile.js command to run, it gave me the error:

Token Info: { myTotp: '1980479983', isValid: true }
Making req {
  URL: 'https://api.challenge.hennge.com/challenges/003',
  reqJSON: {
    github_url: 'https://gist.github.com/sthakur369/233ab97e2d4c4a67630bf6c61f629fe1',
    contact_email: 'sthakur369@gmail.com'
  },
  config: {
    headers: {
      'Content-Type': 'application/json',
      Authorization: 'Basic c3RoYWt1cjM2OUBnbWFpbC5jb206MTk4MDQ3OTk4Mw=='
    }
  }
}
{ message: 'Access denied: Invalid token, wrong code' }

Here is my Stakoverflow link of this question.

Check the Specific Meta Key IF its Meta Value is Empty then… (WP Post Meta Query)

I’m trying to make a wp query to WP Post Meta Table where I want to check the post’s META KEY and its META VALUE if its EMPTY or NOT.

The meta key is wc_pay_per_post_product_ids.

IF the statement is TRUE, display the following:

<h1>The Meta Key Is Empty or NULL</h1>
<div class="row"><div class="col-2">One</div><div class="col-10">Two</div></div>

ELSE:

<h1>The Meta Key Is NOT Empty or NULL</h1>
<div class="row"><div class="col-4"></div><div class="col-4"></div><div class="col-4"></div></div>

Here’s the complete code.

<?php
  global $wpdb;
  $post_id = get_the_ID();
  $meta_value = 'wc_pay_per_post_product_ids';

    $args = array(
        'post_type' => 'post',
        'meta_query'     => array(
        array(
            'post_id' => get_the_ID(),
            'key'     => 'wc_pay_per_post_product_ids',
            'compare' => 'EXIST' // CHECK THE VALUE OF META KEY IF EXISTS?
        ) 
        )
    );

    if ($arg == TRUE) {
        echo '<h1>The Meta Key Is Empty or NULL</h1><div class="row"><div class="col-2"></div><div class="col-10"></div></div>';
    } else {
        echo '<h1>The Meta Key Is NOT Empty or NULL</h1><div class="row"><div class="col-4">ONE</div><div class="col-4">TWO</div><div class="col-4">THREE</div></div>';
    }

?>

Here’s the screenshot of my table:

enter image description here

The issue I’m encountering is it always return the result “The Meta Key Is NOT Empty or NULL” Any idea what’s wrong?

REST API design: communicating order of inputs is important to the user (in POST request)

Let’s say I have a REST endpoint where the order of inputs for a given field is important:

POST Request: api.myrestendpoint.com/evolution-timeline/
inputs: {'this_list_should_be_ordered' : ( 'reptiles', 'birds', 'mammals') }

I’d like suggestions on how one can specify the contract so its clear to the client that the order of inputs is important in order to get sensible results. (i.e. passing in the input as (‘mammals’, ‘reptiles’, ‘birds’) wont give a sensible output).

Notes: Couple of obvious solutions are make the field name so it suggests ordering is important or having the swagger/any other documentation tool state the ordering is important…

here’s obviously some validation that will go into figuring whether the ordering is important on the server side, but in interest of making the api faster, i’d like to make it obvious to the user that the ordering does not make sense/and do some lightweight validation of inputs…

post processing – Difference between DxO’s Nik Collection 3 and DxO PhotoLab 3?

Can someone tell me the difference between DxO’s Nik Collection 3 and DxO PhotoLab 3? They seem so similar but I can’t find any comparison to help me decide.

(If this is somehow the wrong sort of question to post here, please accept my apologies and help me find the appropriate forum. Thanks)

Social media manager tools are unable to add post to my facebook page

I have been using a SMM tool to schedule my posts to my facebook page (and other social media channels) for that matter. It was working fine and the posts were added to the FB page. However, recently it stopped showing the posts on the FB page while all other channels show the posts.

There is no error at SMM tool side. Also, the images attached to the scheduled posts are being added to the Timeline Photos, but the posts are not being created under Posts tab and do not show up under Activity Log!

Please see these two screenshots.

  1. Posts added from SMM tool: https://www.screencast.com/users/shahzaad/folders/Default/media/77636c4d-7c4d-4494-acfb-1e0de0710db0

  2. No SMM tool created post showing up under the Posts tab only manual ones are showing up https://content.screencast.com/users/shahzaad/folders/Default/media/bd55b339-abeb-4e88-b318-c525ba6f6403/LWR_Recording.png

  3. But the images of those automated posts are showing up under Timeline Photos

2020-07-07_21-42-34

I tried with another social media tool as well, but the same result. So it looks like the issue with at FB side. Do I need to change some settings at FB page or something like that?

Adding span tags to post titles using regex

My basic titles are something like

Part One: Part Two

And I’m trying to end up with something like this using the colon as what I find in the regex:

<span class="one-class">Part One:</span><br><span class="two-class">Part Two</span>

This is the original in entry-header.php and I want to continue to have that html:

if ( is_singular() ) {
            the_title( '<h1 class="entry-title">', '</h1>' );
        }
    

The following works as long as there is a colon in the title. If there is no colon, then none of the html gets added.

if ( is_singular() ) {
                        $string = get_the_title();
            $pattern = '~(.+): (.+)~i';
            $replacement = '<h1 class="entry-title"><span class="title-cite-pali">$1:</span><br><span class="title-english">$2</span></h1>';
            echo preg_replace($pattern, $replacement, $string);
        }
    

But I think what I really want is the following, but it doesn’t work. The output is as if my added code is not there.

if ( is_singular() ) {
            $string = the_title( '<h1 class="entry-title test">', '</h1>' );
            $pattern = '~(.+): (.+)~i';
            $replacement = '<span class="title-cite-pali">$1:</span><br><span class="title-english">$2</span>';
            echo preg_replace($pattern, $replacement, $string);
            
        }
    

I think if I could get the above code working, it is preferable since if there was no colon at least the h1 tags would be added.

Invoke action on a “post” in functions.php?

I have a button in admin that invokes a URL (GET) like this:

/wp-admin/post.php?post=1545559&action=edit&bewpi_action=create&nonce=dbc6e6c4frd

It creates an invoice when pressed.

I have access to all variable values in this URL, so I can recreate it. I also have a function in functions.php that gets invoked when an order is paid and complete.

My question is, how can I invoke that URL (or the internal wordpress action) inside my function in functions.php?

Sorry if it’s a basic question. My googling skills failed me.