driftmagazine
Forum Replies Created
-
Forum: Hacks
In reply to: A list of users with a specific role as a link.No problem. π
Thanks anyway, nice that I found a solution.Forum: Hacks
In reply to: A list of users with a specific role as a link.Forum: Fixing WordPress
In reply to: List users with a particular role as a linkForum: Hacks
In reply to: A list of users with a specific role as a link.Still testing, but nothing works.
echo ‘<p> 1 </p>’;
echo ‘ID).'”> ‘ . $fotografer->user_firstname . ‘ ‘ . $fotografer->user_lastname . ‘ ‘;echo ‘<p> 2 </p>’;
echo ‘ID).'”> ‘ . $fotografer->user_firstname . ‘ ‘ . $fotografer->user_lastname . ‘ ‘;echo ‘<p> 3 </p>’;
echo ‘ ‘ . $fotografer->user_firstname . ‘ ‘ . $fotografer->user_lastname . ‘ ‘;echo ‘<p> 4 </p>’;
echo ‘ ‘ . $fotografer->user_firstname . ‘ ‘ . $fotografer->user_lastname . ‘ ‘;Forum: Hacks
In reply to: A list of users with a specific role as a link.Thanks bcworkz.
I’m not sure I understand what you mean.
I have created my own theme, so I have no problem to change it.
But do not understand what I should change?Forum: Hacks
In reply to: A list of users with a specific role as a link.Thanks, here is the most promising code.
<p>7</p> <?php //list each role and each user with that role global $wp_roles; foreach( $wp_roles->role_names as $role => $name ) { $name = translate_with_context($name); echo '<p>List of users in the role '.$role .' ('. $name . '):</p>'; $this_role = "'[[:<:]]".$role."[[:>:]]'"; $query = "SELECT * FROM $wpdb->users WHERE ID = ANY (SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'wp_capabilities' AND meta_value RLIKE $this_role) ORDER BY user_nicename ASC LIMIT 10000"; $users_of_this_role = $wpdb->get_results($query); if ($users_of_this_role) { foreach($users_of_this_role as $user) { $curuser = get_userdata($user->ID); $author_post_url=get_author_posts_url($curuser->ID, $curuser->nicename); echo '<p> <a href="' . $author_post_url . '" title="' . sprintf( __( "Posts by %s" ), $curuser->user_nicename ) . '" ' . '>' . $curuser->display_name .'</a></p>'; } } } ?><p>10</p> <?php // WP_User_Query arguments $args = array ( 'role' => 'fotograf', 'order' => 'ASC', 'orderby' => 'display_name', 'search' => '*'.esc_attr( $search_term ).'*', 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'first_name', 'value' => $search_term, 'compare' => 'LIKE' ), array( 'key' => 'last_name', 'value' => $search_term, 'compare' => 'LIKE' ), array( 'key' => 'description', 'value' => $search_term , 'compare' => 'LIKE' ) ) ); // Create the WP_User_Query object $wp_user_query = new WP_User_Query($args); // Get the results $authors = $wp_user_query->get_results(); // Check for results if (!empty($authors)) { echo '<ul>'; // loop trough each author foreach ($authors as $author) { // get all the user's data $fotografer = get_userdata($author->ID); echo '<li>'.$fotografer->first_name.' '.$fotografer->last_name.'</li>'; } echo '</ul>'; } else { echo 'Inga fotografer registrerade med dina sΓΆktermer'; } ?><p>11</p> <?php // WP_User_Query arguments $args = array ( 'role' => 'fotograf', 'order' => 'ASC', 'orderby' => 'display_name', 'search' => '*'.esc_attr( $search_term ).'*', 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'first_name', 'value' => $search_term, 'compare' => 'LIKE' ), array( 'key' => 'last_name', 'value' => $search_term, 'compare' => 'LIKE' ), array( 'key' => 'description', 'value' => $search_term , 'compare' => 'LIKE' ) ) ); // Create the WP_User_Query object $wp_user_query = new WP_User_Query($args); // Get the results $authors = $wp_user_query->get_results(); // Check for results if (!empty($authors)) { echo '<p> '. $name . ' :</p>'; $this_role = "'[[:<:]]".$role."[[:>:]]'"; $query = "SELECT * FROM $wpdb->users WHERE ID = ANY (SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'wp_capabilities' AND meta_value RLIKE $this_role) ORDER BY user_nicename ASC LIMIT 10000"; $users_of_this_role = $wpdb->get_results($query); if ($users_of_this_role) { foreach($users_of_this_role as $user) { $curuser = get_userdata($user->ID); $author_post_url=get_author_posts_url($curuser->ID, $curuser->nicename); echo '<p> <a href="' . $author_post_url . '" title="' . sprintf( __( "Posts by %s" ), $curuser->user_nicename ) . '" ' . '> ' . $curuser->display_name .' </a></p>'; } } } ?>Forum: Hacks
In reply to: I do not want to the_modified_time changed when admin changeThank you so much!! π
Forum: Hacks
In reply to: I do not want to the_modified_time changed when admin changeThank you so much, unfortunately I do not get the last one to work.
So here I put the last code, maybe completely wrong?<?php /** * Plugin Name: wp_insert_post_data example * Plugin URI: https://gist.github.com/JPry/2e4b074a81d7c8234eb4 * Description: Example of prevnting the modified date from changing. * Version: 1.0 * Author: Jeremy Pry * Author URI: http://jeremypry.com/ * License: GPL2 */ // Prevent direct access to this file if ( ! defined( 'ABSPATH' ) ) { die( "You can't do anything by accessing this file directly." ); } add_filter( 'wp_insert_post_data', 'jpry_filter_insert_post_data', 10, 2 ); function jpry_filter_insert_post_data( $data, $postarr ) { // Only strip the modification time for Administrator role. if ( current_user_can( 'administrator' ) ) { unset( $data['post_modified'] ); } if ( 'bil' === $data['post_type'] && current_user_can( 'administrator' ) ) { // ... } return $data; }Forum: Hacks
In reply to: I do not want to the_modified_time changed when admin changeThanks!!
Why would not you recommend it? Is it something I did not think of?If I want it not to be changed only in the custom post type “bil”?
http://driftmagazine.se/blog/bil/Forum: Fixing WordPress
In reply to: List users with a particular role as a linkI have these two codes I am trying to combine.
<?php $args2 = array( 'role' => 'fotograf', 'orderby' => 'user_nicename', 'order' => 'ASC' ); $authors = get_users($args2); echo '<ul>'; foreach ($authors as $user) { echo '<li><p>' . $user->display_name.'<br>'.$user->user_email . '</p></li>'; } echo '</ul>'; ?><?php //list each role and each user with that role global $wp_roles; foreach( $wp_roles->role_names as $role => $name ) { $name = translate_with_context($name); echo '<p>List of users in the role '.$role .' ('. $name . '):</p>'; $this_role = "'[[:<:]]".$role."[[:>:]]'"; $query = "SELECT * FROM $wpdb->users WHERE ID = ANY (SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'wp_capabilities' AND meta_value RLIKE $this_role) ORDER BY user_nicename ASC LIMIT 10000"; $users_of_this_role = $wpdb->get_results($query); if ($users_of_this_role) { foreach($users_of_this_role as $user) { $curuser = get_userdata($user->ID); $author_post_url=get_author_posts_url($curuser->ID, $curuser->nicename); echo '<p> <a href="' . $author_post_url . '" title="' . sprintf( __( "Posts by %s" ), $curuser->user_nicename ) . '" ' . '>' . $curuser->display_name .'</a></p>'; } } } ?>Forum: Plugins
In reply to: [User Role Editor] User capabilities not updatingThanks, nice work! π
Forum: Plugins
In reply to: [User Role Editor] User capabilities not updatinghttp://driftmagazine.se/wp-signup.php
Make a user account that I set up temporarily as admin.Forum: Plugins
In reply to: [User Role Editor] User capabilities not updatingIt works in Safari.
Forum: Plugins
In reply to: [User Role Editor] User capabilities not updatingThanks!
It’s like the “update” button stuck in the depressed position.
I’ll arrange a test account for you when I can. π
Forum: Plugins
In reply to: [User Role Editor] User capabilities not updatingHave just installed, very useful, thank you!
Same problem here.
That changed when I had clicked in that I did not want to confirm the update again.I also use Chrome.