|
I'm working on a filter for a Custom Post Type . I need it to filter the list depending on the user's role. The way this should work is the following...
- Users in roles "formusers1" and "formusers2" can post. Users can only see their own posts.
- Users in role "formchecker1" can see all posts assigned role "formusers1' and can approve each post.
- Users in role "formchecker2" can see all posts assigned role "formusers2' and can approve each post.
- Users in roles "formsupervisor" and "administrator" can see everyone's posts.
So far I can filter by roles "formusers1" and "formusers2" using:
$query->set('author', $current_user->ID); However, when try to filter the list for role "formchecker1" I see posts from all roles. What am I doing wrong? Here's the rest of the code. Thanks for checking out!
add_action('pre_get_posts', 'filter_posts_list');<br />
<br />
function filter_posts_list($query) {<br />
global $pagenow, $typenow;<br />
<br />
global $current_user;<br />
get_currentuserinfo();<br />
<br />
if (current_user_can('formchecker1') && ('edit.php' == $pagenow) && $typenow == 'mycustomcpt' ) {<br />
$query->set('author', 'formusers1');<br />
}<br />
<br />
if (current_user_can('formchecker2') && ('edit.php' == $pagenow) && $typenow == 'mycustomcpt' ) {<br />
$query->set('author', 'formusers2');<br />
}<br />
<br />
if ((current_user_can('formusers1') || current_user_can('formusers2')) && ('edit.php' == $pagenow) && $typenow == 'mycustomcpt') {<br />
$query->set('author', $current_user->ID);<br />
}<br />
}
|
|
|
|
|
You need to show the code that decides whether a post can be shown or not. I am assuming that the above code has been tested and sets the correct values.
|
|
|
|
|
Hello All,
Sorry if this is the incorrect area to post question, but how do i set a timer in powershell script, so that when the authentication expires, to reset it again?
Many thanks!!
|
|
|
|
|
I'll be creating an Asp.Net Web API for a construction management app I'm working on. I'v created API's before, and I usually create one controller for each functional area. So, for Projects I have a ProjectController, for Jobs there's a JobController, Employees has an EmployeeController. In eah controller I place methods that access the DAL for everything related to that functional area.
Is this the right approach? I'm open to suggestion.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
how to creat website page
|
|
|
|
|
We really can't tell you - it's far, far too big a question for a little text box!
For starters, there is the language(s) you need to choose: HTML and Javascript are pretty much a given, but for any real interaction you will need a back end language as well: C#, VB, PHP, Ruby, Python ... to name just a few. Then there are front end packages: Node.js, Angular, ... the list goes on.
And next databases ... SQL Server, MySql are the most common, but there are others.
Then, hosting: where are you going to put it? You need a domain or people can't get to it, and that normally means a hosting service - so then you have to find out what they provide, and estimate how much resources you will need - and how much you are willing to pay for them!
Finally, there is the type of website you want to develop: a shop front, a blog store, a chat room, a game, an advertising hoarding, ... there are as many of them as there are websites, pretty much.
And all of this comes with a learning curve - while you can create a basic website with just HTML and a free hosting service it won't be at all interactive and so unlikely to attract any visitors.
To add to the fun, we have no idea of your skills, interests or abilities, and that really restricts what you can get up and running in a short time, and severely restricts any advice we could give you.
What I'd suggest is that you look at your current skill set and find a book (or better a course) which builds on on those skills and expands them in the direction you want to go. Addison Wesley, Wrox, and Microsoft Press all do good books on a huge range of web related projects so go have a look at their ranges and see what fits you abilities.
Good luck!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Just write some html.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
By begging or paying large sums. In your case, a very large sum, in advance.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Start HERE to learn HTML[^] - that's the most basic language of the web. Make a web page
Afterwards, move on to CSS (CSS3 these days) - teaches you how to format decorate the page
Then javaScript - gives life to your web page: so when a button is clicked, for example, it does something.
Finally, I prefer PHP. PHP will allow you to build pages uniquely for each user, access databases, move files. Make a real website!
The first three have interactive "try it" areas for you to see the code, modify it, and then see what happens.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
making class in models.py , making migrations but giving errors as below
python: can't open file 'manage.py': [Errno 2] No such file or directory
|
|
|
|
|
Firstly, this has nothing to do with web development. Secondly, the error message could not be clearer.
|
|
|
|
|
Mohammad Shafique wrote: python: can't open file 'manage.py': [Errno 2] No such file or directory You'll need to figure out where it went.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
I am looking for some one that can crate School student_result_management
|
|
|
|
|
Wrong site, try freelancer.com or one of the other code to order sites. We will help you with a coding problem but we do not code to order.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Hello.
If you want solution, contact me.
|
|
|
|
|
hi!)
If you need help, and the question is still relevant and you need
Custom eLearning Solutions . I can help you with this question. Is there an SOW?
|
|
|
|
|
I have this CMS work, at the edit_subject page, I have some problem that say ( The subject update failed.
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '} WHERE id = 1' at line 4)
This is the page
30);
foreach($fields_with_lengths as $fieldname => $maxlength ){
if (strlen(trim(mysql_prep($_POST[$fieldname]))) > $maxlength) { $errors[] = $fieldname; }
}
if (empty($errors)) {
// Perform Update
$id = mysql_prep($_GET['subj']);
$menu_name = mysql_prep($_POST['menu_name']);
$position = mysql_prep($_POST['position']);
$visible = mysql_prep($_POST['visible']);
$query = "UPDATE subjects SET
menu_name = '{$menu_name}',
position = {$position},
visible = {visible}
WHERE id = {$id}";
$result = mysql_query($query, $connection);
if (mysql_affected_rows() == 1) {
// Success
$message = "The subject was successfully updated.";
} else {
// Failed
$message = "The subject update failed. ";
$message .= " ". mysql_error();
}
} else{
// Errors occurred
$message = "There were " . count($errors) . " errors in the form. ";
}
}// end: if (isset($_POST['submit']))
?>
| Edit Subject:
" . $message . "";} ?>
";
echo "Please review the following fields; ";
foreach($errors as $errors) {
echo " - " . $errors . " ";
}
echo "";
}
?>
Subject name:
Position:
{$count}";
}
?>
Visible:
No
/> Yes
Cancel |
I need your help
|
|
|
|
|
Your post is quite poorly formatted, but it looks like you are missing a $ symbol where {visible} should be {$visible}.
|
|
|
|
|
Your code is vulnerable to SQL Injection[^]. NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.
PHP: SQL Injection - Manual[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
What are the best languages for web development?
|
|
|
|
|
The question is really broad and so opinionated.
My champion for client-side development is Typescript. On the one hand, it allows to bee more productive due to static typing (in comparison to javascript). One the other hand it has a mature community. Also, it doesn't generate as much underlying javascript as Fable, Elm, etc which allow event more type safety.
For the server-side I prefer F# due to mature .NET Core framework and functional defaults. Although the choice here is huge: js, C#, Java, Ruby, PHP, Go, Erlang. Literally, everything that is suitable for your specific needs.
|
|
|
|
|
Typescript is javascript, theres no way to code typescript without javascript they are the best friends so you can use classes in javascript, there are many options in this world. But nowadays Javascript is leading startups cause you can do frontend and backend same language ( also you can code Frontend with Typescript).
But if you project needs super-fast responses from Backend, so choose another language more powerful like Golang or Java, if not go with nodejs.
|
|
|
|
|
If you are starting a project, I strongly recommend you Nodejs (Javascript) for Backend and for FrontEnd Jquery, React, Angular, and soo on, Everything is javascript, don't break your head.
|
|
|
|
|
There are many languages that can help you with web development. However; the clear answer, in my opinion, would be JavaScript because once you have learned this language you can use it on the server-side (Node.js) and client-side as well. So start learning JavaScript then after that learn some framework which interests you. Thanks.
Cheers,
Jin
|
|
|
|
|
You can see there is no surprise, JavaScript is the king of Web development but Python is equally good.
|
|
|
|
|