get user role. parameter id return type string [closed]

You should use WordPress functions to get the user role by user id. Please try code given below: function user_role_parameter($user_id) { $user_meta = get_userdata($user_id); if ( !empty($user_meta) ) { $user_roles = $user_meta->roles; $user_role=””; foreach( $user_roles as $role ){ $user_role .= $role . ‘, ‘; } return $user_role; } else { return “”; } }

Parse error: syntax error, unexpected ‘}’ in C:\xampp\htdocs\admin\products.php on line 148 [closed]

I have updated your code here. so use this below code. you have forgot close this ) in this line like this while ($row=mysql_fetch_object($query)) <tr> <?php include(‘sql_connect.php’); ?> <?php $sql=”select * from hp”; $query=mysql_query($sql); if(mysql_num_rows($query)>0) { $i=1; while ($row=mysql_fetch_object($query)){ ?> <th scope=”row”><input type=”checkbox” /></th> <td class=”tm-product-name”><?php echo $hp_model; ?> </td> <td><?php echo $hp_type; ?></td> <td><?php … Read more

Running a php code after User clicks a button? [closed]

You can wrap your code in a function and use a button to activate it. Create a button and assign a function to it’s onclick event: <span onlclick=”javaSubscribe();”>Subscribe</span> Now, make an AJAX request to your server after clicking the button: function javaSubscribe() { // We need the ID for user and tag. Let’s retrieve it … Read more

php snippets in html are being commented out

You don’t display anything in shorcode’s function, you just return what has to be displayed. Your code should be: function phpTest() { return ‘<p>some text</p>’; } add_shortcode(‘test’, ‘phpTest’); Update: if your function contains anything, which displays data, use it as follows: function phpTest() { ob_start(); // your code goes here return ob_get_clean(); } add_shortcode(‘test’, ‘phpTest’);

What is proper way to use the php if statement? [closed]

I assume you are trying to create a new template file linked to a WordPress page. Additionnal documentation : https://codex.wordpress.org/Theme_Development#Basic_Templates To make so, you would need to do something like this : <?php /* Template Name: My first template file */ get_header(); ?> <!– Main body –> <?php if (1<2) { echo “Add multiple lines … Read more

php grabbing every post made?

Based on WordPress template hierarchy, categories are displayed using the category.php template. So in other to display your preferred category, you’ll need to create a category.php file, and use the query below: $cat_query = new WP_Query( array( ‘post_type’ => ‘post’, ‘cat’ => $cat, //WordPress global for getting the current category ‘posts_per_page’ => 5, ) ); … Read more

Display biography post for today’s birthday person

Well there is no Generic solution for your problem/query as WordPress is not Specifically made Biography directory. Solution will depend on the approach you have followed. Have you created Custom User Role and add biography user under that user role OR Have you created Custom Post Type for Biography and add posts under that ? … Read more