PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, August 26, 2022

[FIXED] How to print the object values in WordPress

 August 26, 2022     handlebars.js, javascript, php, wordpress     No comments   

Issue

I want to make changes to the ultimate member plugin template file. enter image description here

Now I want to check the details that are inside the user object but I don't know how to print or var dump the user object can anyone help me with that, please?

Thanx in advance :)


Solution

The code you showed us is part of a template object embedded in the HTML your server sends to your user's browser. This object gets interpreted by some Javascript code your server also sends.

Debugging this stuff is tricky because various languages are embedded in each other. In your case you want to see the data variable. It is in ...

  • Javascript,
  • embedded in a template object,
  • interpreted by other Javascript,
  • embedded in HTML,
  • embedded in php.

To debug it you first have to guess what is embedded in what. And you need a bit of luck to guess correctly. I am guessing.

The template itself can contain Javascript code, and you're asking about the value of data in that Javascript code. So, if you want to see that data you can put a Javascript console.log() call into the template for debugging purposes. To do that, change this line

<# _.each( data, function( user, key, list ) { #>

to this

<# console.log('data from member grid', data ); _.each( data, function( user, key, list ) { #>

The output from console.log appears in the console tab of your browser's devtools: it's generated by the browser not your WordPress / php server.

You could, if you want to use your browser devtools Javascript debugger, use this line instead.

<# debugger; _.each( data, function( user, key, list ) { #>

The debugger will engage right before the _.each loop and let you examine your variables, like data.

Notice that my suggestions are not debugged, and I have no way to debug them.



Answered By - O. Jones
Answer Checked By - David Goodson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing