How to customize User points section in user profiles - drupal

I'm using User Points module which adds an User Points tab to the users profiles.
I want to remove the link "View" from the user Points tab in User profiles, and leave only the score number.
I'm looking for the template using theme developer module:
http://dl.dropbox.com/u/72686/userpoints.png
However, the template user-profile-item.tpl.php contains only:
<dt<?php print $attributes; ?>><?php print $title; ?></dt>
<dd<?php print $attributes; ?>><?php print $value; ?></dd>
and I cannot do a lot with it.
The template contains only:
<div class="profile">
<?php print $user_profile; ?>
</div>
So, where is the template I need to modify how the User Points are displayed in user profiles ?
thanks

The user profile is a bit tricky because it's so generic. In this case you don't want to change the markup but the actual content.
You can do this by.
use hook_preprocess_user_profile where you can alter the value used
Implement hook_user yourself, and overwrite the data provided by user points module to remove the unwanted links. (They are only available if you have permission)

Related

Wordpress Advanced Custom Field - Field Not Displaying

I am building an artist directory page which displays all the artist pages as thumbnails with captions.
I would then like it so that when you click on one of the thumbnails it takes you to that page and shows the various fields ACF.
However, it only shows the title and I cannot get it to display the bio field at all!
<h1><?php echo $post->post_title; ?></h1>
<div id="artist-bio">
<?php the_field('artist_bio'); ?>
</div>
first, it's a good practice to check if your fields have been set in the first place. You can test like this:
if (get_field('artist_bio') {
the_field('artist_bio');
} else {
echo "Artist bio has not been set";
}
If it's claiming that it hasn't been set, yet you're sure it is, then there's probably an issue with the loop. Are you inside the default loop, or are you running a custom query? In the latter case you would need to modify your command like so: the_field('artist_bio', $post->ID).

How can I create a link to a specific page in wordpress?

It seems like a simple task, but I'm having difficult time finding any information on this. Basically I have an "Events" page created in wordpress to which I want to create a link on my main page. I do not want it to be static like (https://mysite.com/events). Is there a way to do it dynamically?
You want to use the get_permalink() function to write the link - http://codex.wordpress.org/Function_Reference/get_permalink
This function accepts an argument which is the post or page ID (and defaults to the ID of the current page), so if your Events page is ID #11, it would look like to following to also have the link text match the page title (should it change to "Events!" in the future, for example):
<?php $events_page = get_post(11); ?>
<?php echo $events_page->post_title; ?>

Wordpress admin: set category from variable instead of checkbox

The only way to set a category to a new post seems to be to select the appropriate one via a check-box before submitting it.
At best, you can set a default category as an option in case no box has been checked by the user.
This is really a problem for me as my admin menus are and have to be the categories themselves.
As I mentioned, in my WordPress admin I have a custom menu listing category names. Clicking on one leads directly to the generic "add a new post" page.
What makes it less generic is that I have inserted the category ID within this link, like this: "wp-admin/post-new.php?cat=5".
At this point,I would like not to check a category from a box before submitting the new post. Instead, I want WordPress to use the variable provided in the URL and submit the category ID accordingly when my new post is ready to be published.
Is it possible?
Which file would I have to edit in order to achieve this?
Any other idea that would lead to the same result?
You can use an extension that you will develop. It is better than trying to modify Wordpress core files.
I did something that may help you in one of mine. Using this :
if(is_admin()){
add_action('post_submitbox_misc_actions', 'plugin_add_custom_box');
}
function plugin_add_custom_box(){
?>
<div class="al2fb_post_submit">
<div class="misc-pub-section">
<?php
echo '<input type="checkbox" id="plugin" name="plugin_action" value="1"/>';
echo '<label for="plugin">';
_e("Label", 'myplugin_textdomain');
echo '</label> ';
?>
</div>
</div>
<?php
}
This add a custom checkbox. Using the same name for the checkbox here than checkboxes already displayed by Wordpress and checking it analysing your URL, you will probably be able to store the category you want without modifying core files.

How to disable page's title in wp-admin from being edited?

I have a wp-network installed with users that can create pages in each site.
Each of those pages get a place in the primary menu, and only one user have permission to create all this menu.
I want to create a user only to be able to edit the content of the pages, but not the title.
How can I disable the title of the page to be edited from the admin menu for a specific user, or (far better) for a capability?
I thought only a possibility, that's editing admin css to hide the title textbox, but I have two problems:
I don't like to css-hide things.
I don't know where is the admin css.
I know php, but don't know how to add a css hide to an element for a capability.
You should definitely use CSS to hide the div#titlediv. You'll want the title to show in the markup so the form submission, validation, etc continues to operate smoothly.
Some elements you'll need to know to implement this solution:
current_user_can() is a boolean function that tests if the current logged in user has a capability or role.
You can add style in line via the admin_head action, or using wp_enqueue_style if you'd like to store it in a separate CSS file.
Here is a code snippet that will do the job, place it where you find fit, functions.php in your theme works. I'd put it inside a network activated plugin if you're using different themes in your network:
<?php
add_action('admin_head', 'maybe_modify_admin_css');
function maybe_modify_admin_css() {
if (current_user_can('specific_capability')) {
?>
<style>
div#titlediv {
display: none;
}
</style>
<?php
}
}
?>
I resolved the problem, just if someone comes here using a search engine, I post the solution.
Doing some research, I found the part of the code where the title textbox gets inserted, and I found a function to know if a user has a certain capability.
The file where the title textbox gets added is /wp-admin/edit-form-advanced.php. This is the line before the textbox
if ( post_type_supports($post_type, 'title') )
I changed it to this
if ( post_type_supports($post_type, 'title') and current_user_can('edit_title') )
That way, the textbox is only added when the user has the capability called "edit_title"
When this IF block ends few lines after, I added:
else echo "<h2>".esc_attr( htmlspecialchars( $post->post_title ) )."</h2>";
To see the page title but not to edit it, when the user hasn't got "edit_title" capability.
Then I had already installed a plugin to edit user capabilities and roles, wich help me to create a new capability (edit_title) and assign it to the role I want.

Custom style user profile pages in Drupal 6

I wish to display my tabs (View / Edit etc.) in a sidebar and not on top of the node but only when I am viewing my own profile (maybe when viewing other users profiles too). In my page.tpl.php I have this snippet:
<?php if (!empty($tabs)): ?><div class="tabs-wrapper"><?php print $tabs; ?></div><?php endif; ?>
And I guess it should be something like if (!empty($tabs) && !$user_profile_page) but I can't make it work.
You want to do this using multiple template files in your theme. In your theme you need to copy page.tpl.php and rename it to either:
page-user.tpl.php
(theme all user profile pages at once)
page-user-<id>.tpl.php
(theme a particular user's profile (where <id> is the user id)
Then you just style those particular template files with the tabs you want (no if statements required).

Resources