get_post_meta with related user
Try to use get_posts() $current_user = get_current_user_id(); $args = array( ‘post_type’ => ‘post’, ‘author’ => $current_user, ‘post_status’ => ‘publish’, ); $all_posts = get_posts( $args );
Try to use get_posts() $current_user = get_current_user_id(); $args = array( ‘post_type’ => ‘post’, ‘author’ => $current_user, ‘post_status’ => ‘publish’, ); $all_posts = get_posts( $args );
I am not sure too much about the code but i think you forgot to echo $user->url So just replace all $user->url with echo $user->url
Sounds like this is what you’re running into. admin_page_access_denied may be the hook you want to use for this. try function dont_show_cheatin_page() { if ( current_user_can( ‘do_not_allow’ ) ) { wp_safe_redirect( admin_url()); // custom redirect instead of Cheatin 403 page exit; } } add_action(‘admin_page_access_denied’, ‘dont_show_cheatin_page’);
Age-old question I guess. Hire someone who, you think, and can understand, is a good fit for you according to their portfolio and past activity. To this day, tracking someone is not that tough. Simply follow them for some days in their social network, and you can sum up something. Even you can [sometimes] verify … Read more
If you’re new in WordPress dev, I would recommend this plugin https://wordpress.org/plugins/members/, there is an option to allow you to disable content based on User role, you can also easily creating role with the plugin. As for your question: if you don’t want the user with role subscriber for viewing content, I’m using twentysixteen theme … Read more
Your problem is that current_user_can() takes a capability not a user role. So, to check for an administrator, for example, you might use: if ( current_user_can( ‘manage_options’ ) ) { … } because ordinarily only admins can manage options. You’d have to tie your custom user roles to capabilities that correspond to their roles, which … Read more
pre_get_users is the action that is fired before a user query is run. You need to check the context of the action to make sure you’re on the main users screen. You can then alter the query with any parameters accepted by WP_User_Query. A quick example: function wpd_filter_users( $query ) { $screen = get_current_screen(); if( … Read more
You just need to move the capability check “inwards”: function wpse_230369_quote_of_the_day( $user ) { $quote = esc_attr( get_option( ‘quote_of_the_day’ ) ); ?> <div class=”visible-only-for-admin”> <h3>Quote of the Day Input Field</h3> <table class=”form-table” > <tr> <th><label for=”quote_of_the_day”>Quote of the Day</label></th> <td> <?php if ( current_user_can( ‘administrator’ ) ) : ?> <input type=”text” name=”quote_of_the_day” value=”<?php echo $quote … Read more
First you need to make group and subgroup. You can use wordpress existing User Role or you can make custom user role (group) by own. Members is a nice plugin to create custom role. For example your main group is “Group1” and subgroup is “Subgroup1”. First you need to check current user role (Group of … Read more
This will print User Role global $current_user; $user_role = $current_user->roles[0]; echo $user_role; Use above code, where ever you want to display user role.