For my web in Wordpress I need to create a page where users will see the content they have uploaded on the web (videos, comments, events, etc.), but in this page is only going to be displayed the information that they have uploaded and not that of other users. That is, what I need is to type the code so that only the information generated by the user that is logged in is displayed. I have made many attempts but I am aware that I can not conclude, correctly, the last part of the code, and that I have to add the line code that allows to display right result:
Is it correct to do it with echo or return? how should this line of code be? I have made many attempts, but without success (see code below).
Do I have to use the function and add_filter commands into the code?
If you could have a look at the code shown below. For your information, the following is the output of this code: Array
Below I inlcude some links where I have been searching on regarding this topic:
https://codex.wordpress.org/Class_Reference/WP_Query#Code_Documentation https://codex.wordpress.org/Function_Reference/get_posts https://wordpress.stackexchange.com/questions/69614/logged-in-user-id-as-post-id Get post ID of current logged in user and add a link to the menu
Code:
<?php // Accedemos a la variable global
global $current_user;
// Obtenemos la informacion del usuario conectado y asignamos los valores a
las variables globales
get_currentuserinfo();
// Guardamos el nombre del usuario en una variable
$usuario = esc_attr($current_user->user_login);
$args = array(
'author' => $current_user->ID,
'orderby' => 'post_date',
'order' => 'ASC',
'posts_per_page' => -1 // no limit
);
$current_user_posts = get_posts( $args );
echo $args;
?>
Thanks