Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have enabled the setting to provide a link in the user's account page to their content_profile form when it has not been completed, but I am looking for another way to remind users to create their profiles because many are not doing so.
Could this be achieved with a block? If so, can anyone suggest how please?
Comment | File | Size | Author |
---|---|---|---|
#16 | block-by-role-profile-picture.png | 26.69 KB | dmetzcher |
Comments
Comment #1
Matt BI've worked out some PHP for the block body:
Just change '$type="profile";' to be the name of your profile content type. I guess someone more familiar with the module could refine the above, but it works for me! - the last line might need to be 'print l($text, "user/" . $user->uid . "/profile/" . $type);'
Now I just need to work out what to put in the "Page specific visibility settings" (with "Show if the following PHP code returns TRUE" selected) to only display the block if the user has not created their profile yet....
Comment #2
Matt BI'm currently working on:
for the block visibility - just need to fix the "/* now return TRUE if $user has not created their profile (FALSE if not).... */" comment! At the moment this stops the block from being displayed on the users account pages (content profile provides a link here) and on the admin pages (although you'd hope a user with admin rights will have created a profile) as it just gets in the way.
Comment #3
Matt BOk, figured out the block visibility:
It's a bit of a hack and could possibly be written better - so suggestions are welcome. It'd be better if the Content Profile provided a block that did this....
Comment #4
Patroclas CreditAttribution: Patroclas commentedThanks for this Matt, will give it a try later.
Comment #5
Patroclas CreditAttribution: Patroclas commentedI could not get this to work on my site.
The block appears even for unregistered users and includes a '1' under the title. If I restrict visibility by role of the block itself, it shows even if the cp profile has been created.
Just another idea - If CP module can place a line of text on the user page if no profile has been created, is there not a way to place the same text on other pages via templates maybe?
Comment #6
Matt BSorry you couldn't get it to work - mine's still working fine. Perhaps this should be a feature request for CP, to provide a block?
Comment #7
Patroclas CreditAttribution: Patroclas commentedI have achieved what I need with the Rules module. Users with no CP are redirected to the appropriate form and a message is displayed. It is possible to display a block but this depends on switching roles around - I didn't want to do that because I am using LM PayPal to set subscription roles.
CP is exposed to Rules - it opens up a range of useful possibilities. Thanks to the module author for providing that!
Comment #8
lias CreditAttribution: lias commentedThis is exactly the approach I took, Rules rules! http://drupal.org/project/rules
Comment #15
dmetzcher CreditAttribution: dmetzcher commentedI did the following. Note that the code below will check four things. You can modify sections of the code below (or remove them) to suit your own needs. The site I'm working on it rather complex in terms of features and I needed a way to let new users know what they had and had not done yet. The effect is a numbered list with each item crossed off as it is completed. The block is no longer displayed when all items have been completed.
If so, short-circuit everything and do not display the block. I create the administrator role and explicitly assign it all permissions when I set up a Drupal site. This makes it easy to grant full admin status to multiple accounts and I rarely have to log into the super-admin account that Drupal creates (database updates after installing modules is really the only time it's necessary). I also assign this role to the super-admin account for consistency.
If not, display the block. This is a role I created for the site I'm working on right now. It's a site that ties into Second Life and allows accounts on my site to be linked to their avatars (automatically, using the SlUser module). Once linked, they are considered "verified" and SlUser assigns the "verified user" role to them.
If not, display the block.
If not, display the block.
This code goes into the block itself:
This code goes into the block's "Page specific visibility settings" -- be sure to select the radio button labeled "Show if the following PHP code returns TRUE (PHP-mode, experts only).":
(Note that the checkbox labeled "authenticated user" under "Show block for specific roles" must be checked on the block's configuration page in order to hide this block from anonymous users -- you don't want them seeing this because it they haven't signed up yet.)
Comment #16
dmetzcher CreditAttribution: dmetzcher commentedAttached is a screenshot of what the block I outlined in comment 15 looks like.